wesleytodd / nighthawk

A wrapper around Express' router for the browser
ISC License
55 stars 7 forks source link

Update router.js #12

Open ynonp opened 6 years ago

ynonp commented 6 years ago

Hi,

Links to external hosts are now automatically ignored

wesleytodd commented 6 years ago

Hey @ynonp, thanks for the report!

I believe that the case of external origins, aka el.host !== window.location.host, are handled in the intercept-link-clicks module, which nighthawk uses to intercept all the anchor clicks. Here is the relevant code for that: https://github.com/wesleytodd/intercept-link-clicks/blob/master/index.js#L121

I could very well be wrong, so if you could provide a test case for the issue, I would be happy to resolve this and publish a patch. The test for this behavior in the underlying module can be found here: https://github.com/wesleytodd/intercept-link-clicks/blob/master/test/intercept.js#L88

In theory, if you call onClick directly with your own anchor element you could hit this behavior and bypass intercept-link-clicks, so if something like this is your use case I would love to see an example, and maybe I can help find another way.