Skip to content

Problem with "link" method #331

@mmdm95

Description

@mmdm95

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions