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

Ignore and redirect external links #3

Closed
mythz opened this issue Apr 25, 2019 · 3 comments
Closed

Ignore and redirect external links #3

mythz opened this issue Apr 25, 2019 · 3 comments

Comments

@mythz
Copy link

mythz commented Apr 25, 2019

This library takes over external links so when you click on an external link:

<a href="http://google.com">link</a>

It instead redirects to:

http://localhost:5000/http://google.com

My current workaround is detect an external link and replace the location like:

if (u.indexOf('/http') === 0) {
    location.replace(u.substring(1))
    return;
}

But it still temporarily shows the invalid URL in the browser before redirecting and you can't use location.href = u.substring(1) because it adds the invalid URL to the browser history so when you go back it goes back to the URL.

IMO external links should not be caught and redirected immediately, or if you don't agree with that default behavior can you provide an option to not handle external links.

Alternatively it would be more flexible if there was a callback where we can intercept the location change so we can immediately redirect ourselves using location.href.

@lukeed
Copy link
Owner

lukeed commented Apr 25, 2019

Noticed this today as well. I typically have target="" on external links, so I've avoided this issue thus far.

Will fix it asap

@lukeed lukeed closed this as completed in b4561f9 Apr 25, 2019
@mythz
Copy link
Author

mythz commented Apr 25, 2019

Thanks! Can you publish an update to npm when you have a chance, Cheers 👍

@lukeed
Copy link
Owner

lukeed commented Apr 25, 2019

Released now as 1.0.1.

I was seeing if I could squeeze out any additional byte shavings... I did 😇 Took it from what would have been 846B to 829B. Free feature

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

2 participants