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

0.7 has broken pattern matching #74

Closed
Javiani opened this issue Apr 8, 2018 · 7 comments
Closed

0.7 has broken pattern matching #74

Javiani opened this issue Apr 8, 2018 · 7 comments

Comments

@Javiani
Copy link

Javiani commented Apr 8, 2018

Hi!
First of all, keep up with this awesome library! I'm using as part of my own framework and its the best router I've ever found for javascript.

However, yesterday I have a little headache, I had to npm install it for a new project, but I got the 0.7 version which is not working as expected, I coudn't match any of my routes using router.get() ( using hash ), before I go crazy I compared the new project to a older one then I realized that was a version issue. So I forced the npm version to 0.6 and it worked like a charm.

I don't know if something changed and documentation is not updated or something like that, I'm just warning you that the library is currently broken in 0.7 version.

Bye! o/

@baseprime
Copy link
Owner

Hi @Javiani, thanks! Could you give a code example of how you’re using Grapnel? Are you using Webpack or including it using <script> tag?

@Javiani
Copy link
Author

Javiani commented Apr 14, 2018

Hi @baseprime !

I'm using Webpack, and the url is :
http://localhost:3000/playlists/#/advisor/clark-kent

I'm trying to get advisor name by using :

const router = new Grapnel()
router.get('/advisor/:analyst', console.log)

console.log is not being called for that route.
It only works on 0.6 version.

Thanks!

@baseprime
Copy link
Owner

Are you loading window as an external in your webpack config?

Check out this GutHub Issue for more info

@Javiani
Copy link
Author

Javiani commented Apr 14, 2018

Hi @baseprime , I tried to do that, but it still don't work.
One thing I notice is that the router.get('*') works... I think it might be related to some async behavior on my application.

I think you can close this issue because I guess that I'm the only one that can reproduce this issue, so it's probably related to my implementation...

Thanks!

@meeh0w
Copy link

meeh0w commented Oct 11, 2019

@Javiani @baseprime

I can confirm that this has become an issue in 0.7 -- 0.6.3 works fine.
We're using this lib in an old and very limited environment (Adobe Extension) which runs Chrome 41 and hence we rely on location.hash.
Older version, when reading current path in hash mode, used to only return location.hash. However, the new version returns entire location.pathname.

Because Grapnel relies on this.path() when parsing routes, and the Route object receives the location.pathname instead of location.hash, it won't recognize any of your routes and it'll end up matching the wildcard 404 (if you have it defined).

@baseprime baseprime reopened this Oct 19, 2019
@baseprime
Copy link
Owner

@Javiani @meeh0w Wish we had caught this sooner. Thanks for your help!

@crisperpo
Copy link

I am still having this issue in version 0.7.2

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

4 participants