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

Support trailing slashes, not extraneous ones #3158

Merged
merged 1 commit into from
Apr 1, 2016
Merged

Support trailing slashes, not extraneous ones #3158

merged 1 commit into from
Apr 1, 2016

Conversation

taion
Copy link
Contributor

@taion taion commented Mar 7, 2016

On further thought, the current behavior, despite being tested, is clearly just buggy. This will make life easier and opens the door to having a much simpler algorithm for checking isActive in the indexOnly sense.

@taion
Copy link
Contributor Author

taion commented Mar 7, 2016

Technically this is breaking, but IMO the old behavior is clearly not just wrong but actively buggy.

@timdorr
Copy link
Member

timdorr commented Mar 7, 2016

Seems fine to me. This should be against next, not master. Does this need a corresponding doc update?

@taion
Copy link
Contributor Author

taion commented Mar 7, 2016

This isn't documented. The intention is that this is safe for a patch-level release.

@timdorr
Copy link
Member

timdorr commented Mar 7, 2016

But it's breaking, so semver dogmatics are going to be pissed.

@taion
Copy link
Contributor Author

taion commented Mar 7, 2016

All bugfixes are technically breaking – this is more in that category, though.

@taion
Copy link
Contributor Author

taion commented Mar 7, 2016

Updated the code to catch a case I was missing.

@timdorr
Copy link
Member

timdorr commented Mar 7, 2016

Personally, I'm ambivalent about it. I don't think there's a practical problem with it and this looks mergable as-is. I'm just looking out for the purists, who will undoubtedly raise a stink.

@taion
Copy link
Contributor Author

taion commented Mar 10, 2016

I need to improve this impl a bit. Don't merge this as-is.

@taion taion changed the title Support trailing slashes, not extraneous ones [WIP] Support trailing slashes, not extraneous ones Mar 10, 2016
@taion taion added the bug label Mar 18, 2016
@taion taion changed the title [WIP] Support trailing slashes, not extraneous ones Support trailing slashes, not extraneous ones Mar 18, 2016
@taion
Copy link
Contributor Author

taion commented Mar 18, 2016

This is good to go now.

@taion
Copy link
Contributor Author

taion commented Mar 18, 2016

I think we initially (unintentionally) added support for this in 6eba291 to, at a guess, better handle some edge cases with how we were combining route paths for purposes of building patterns (e.g. with training slashes and concatenating them, back when we did that).

This is no longer relevant, so we can finally unwind all of that.

@@ -52,7 +52,7 @@ describe('v1 Link', function () {
Michael
</Link>
<Link
to="hello/ryan" query={{ the: 'query' }}
to="/hello/ryan" query={{ the: 'query' }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't supposed to work, and now in fact it actually doesn't.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To elaborate on "not supposed to work" – links like this will do random, dangerous things when used with e.g. browser history right now, given the lack of support there for relative links.

@geminiyellow
Copy link

thanks @mxstbr .

account/setting === account////////////////////////////////////setting is a bug.

@ryanflorence
Copy link
Member

Seems good, are there open issues associated with this fix? I'd like to see what problems it causes, also would like to see why @mjackson had it work the other way originally. Naively looking at the test cases I like the pull request's better.

@taion
Copy link
Contributor Author

taion commented Mar 18, 2016

There's a small risk that this breaks someone. Less so the extraneous slashes bit, more with https://github.com/reactjs/react-router/pull/3158/files#diff-ee3bac4c318eeb54a00eedf5f9c2fd8aR55, though perhaps we can add some sort of workaround there to keep the old (but IMO buggy) behavior working.

The main benefit is that this lets us make the isActive check much faster for the indexOnly case, since we'd literally just be able to do a string comparison against the current pathname instead of re-running matching.

@taion
Copy link
Contributor Author

taion commented Mar 22, 2016

Rebased.

@timdorr
Copy link
Member

timdorr commented Apr 1, 2016

LGTM. Revert my merge if this looks terrible.

@timdorr timdorr merged commit 7d04245 into remix-run:master Apr 1, 2016
@taion
Copy link
Contributor Author

taion commented Apr 1, 2016

Would you be okay with reverting this even if I don't think it looks terrible?

I stand by my choice to call this a non-breaking bugfix, but all the same, I'd rather we release a v2.1.0 without this change first.

@taion
Copy link
Contributor Author

taion commented Apr 1, 2016

(I probably should have noted that on the PR)

@timdorr
Copy link
Member

timdorr commented Apr 1, 2016

I'd say rewind master locally, splice in a 2.1.0 commit and tag, and then replay this back on. No revert and revert-revert needed.

@taion
Copy link
Contributor Author

taion commented Apr 1, 2016

It's a little ugly to release off master though. Then again, reverting and un-reverting is ugly too.

FWIW, my thinking ATM is that we release master pre-this PR as 2.1.0, then resolve this PR plus deprecate nested absolute paths and do whatever we can w/link semantics for 2.2.0 (probably just optimize <IndexLink>s and maybe add a deprecation for non-index <Link>s when the behavior will differ).

But I don't have npm access so I can't make this happen anyway.

@taion taion deleted the isActive-extraneous-slashes branch April 1, 2016 15:59
@timdorr
Copy link
Member

timdorr commented Apr 1, 2016

You can make the tags, so Ryan or Michael can check them out and publish easily enough.

@taion
Copy link
Contributor Author

taion commented Apr 1, 2016

Not exactly – the version/publish cycle goes through our release tooling, so the tagging shouldn't be done separately from the release. See https://github.com/reactjs/react-router/blob/master/scripts/release.sh.

And since the blocker is getting a release out, just tagging it isn't going to accomplish much anyway :p

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

Successfully merging this pull request may close these issues.

4 participants