Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with "link" method #331

Open
mmdm95 opened this issue Jun 16, 2023 · 0 comments
Open

Problem with "link" method #331

mmdm95 opened this issue Jun 16, 2023 · 0 comments

Comments

@mmdm95
Copy link

mmdm95 commented Jun 16, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant