navigo icon indicating copy to clipboard operation
navigo copied to clipboard

Problem with "link" method

Open mmdm95 opened this issue 2 years ago • 0 comments

Hi, I found a problem with link method, it has below functionality:

function link(path) {
  return "/" + root + "/" + clean(path);
}

But it cause problem through using it. For example:

// when I use it as below
link('/')

// result: //

// OR ---
link('/login')

// result: //login

// This happens because root may have been empty string
const router = new Navigo('/'); // root: '/' and it'll be cleared --> root: empty string

I think it must trim below part for slashes:

// use REGEXP to trim slashes
clean(root + "/" + clean(path));

// Example: if we have '/login'
// It will be:
// (clean('/login')) --> login
// then --> '/' + 'login' --> '/login'
// and problem will solve I guess

Thanks for your time

mmdm95 avatar Jun 16 '23 11:06 mmdm95