Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
`relative_url_for` trips on anchors #30
This, however, fails for URLs with an anchor (e. g.
Flask introduced the
Here is my attempt at fixing the issue: https://github.com/homeworkprod/Frozen-Flask/commit/7fd02204f6666cf1df83feff88c64ab1193d3a20
The patch seems to solve the issues I encountered. However, five tests still fail. Also, as URLs are aggregated in a set, further changes and maybe design decisions might be necessary regarding the uniqueness of an URL (so this might or might not include the anchor).
Special attention is required for the two cases I gave examples for above (the key part here is the slash [not] placed right before the hash mark); the tests probably need to be extended to cover both cases (note that one, as opposed to the other one, should result in a directory being created).
Apart from that, I wonder what will happen to query strings …
I think that
Could you make a pull request? (Tiny nitpick, I’d rather do
As to query strings, you’re right to wonder. URLs that differ by their query strings are not the same (you app could respond with different content based on the query string.) The problem is that they would map to the same "frozen" filename, which means that the one generated last would overwrite the file, and the order is not defined. I suppose the best we can do is write "Don’t do that, the results are undefined." in the docs.
Here is the PR, though incomplete: #32
I agree that URLs are basically the same if they only differ in anchors and query arguments.
FYI, my (maybe kinda special) case is that I want slugs in my URLs, but I want to be able to change them afterwards without breaking (as in 404) "perma"links. Because this doesn't apply to
As a result, I'm not sure if dropping the anchor altogether is what I want – at least not in the final generated build that does not use relative URLs; just for local development without a web server and using relative URLs, dropping the anchor might be ok, though.