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

Match query params with hash-based routing #73

Open
milesfrain opened this issue Jun 2, 2020 · 5 comments
Open

Match query params with hash-based routing #73

milesfrain opened this issue Jun 2, 2020 · 5 comments

Comments

@milesfrain
Copy link
Member

I don't think this is possible with properly formatted URLs, since the query param should come before the anchor tag.
https://stackoverflow.com/questions/12682952/proper-url-forming-with-query-string-and-anchor-hashtag

Sure, you can get this working with incorrectly-formatted URLs (query after anchor), but other sites are unlikely to present the URL this way (e.g. github OAuth).

Should I add a note about this in the guide?

@garyb
Copy link
Member

garyb commented Jun 2, 2020

There's nothing wrong with have a query-looking part in the anchor, it's perfectly valid according to RFC 3986, it's just that it won't be part of the actual query, it'll be part of the "fragment" (anchor) instead.

So /#foo?bar=baz is a completely valid URI, it's just ?bar=baz will not be treated as a query string by webserver and such.

@garyb
Copy link
Member

garyb commented Jun 2, 2020

From the spec:

A fragment identifier component is indicated by the presence of a
number sign ("#") character and terminated by the end of the URI.

   fragment = *( pchar / "/" / "?" )

So you can see from the ebnf there that ? is definitely allowed.

@milesfrain
Copy link
Member Author

Would it be worth noting the ordering restriction in the guide? For example, we don't want users struggling with trying to figure out how to parse this with hash-based routing:

/?bar=baz#foo

@garyb
Copy link
Member

garyb commented Jun 2, 2020

I don't think so... it seems pretty clear to me that hash based routing only deals with things after the #?

@garyb
Copy link
Member

garyb commented Jun 2, 2020

Actually, if it tripped you up, I'm wrong in that assumption, and adding a note certainly wouldn't do any harm.

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

No branches or pull requests

2 participants