FIX: Do not keep old URL in history (PR #13367)

Clicking on an incomplete link to a topic (/t/ID) from another post created two history entries: one for /t/ID and another one for /t/SLUG/ID. Going back took the user to /t/ID which redirected them again.

GitHub

This seems backwards to me… replaceURL: true should prevent the URL being kept in history. The default (replaceURL: false) should add a history entry. Do we have a bug deeper in the DiscourseURL module?

I want to confirm this as part of another bug I’m looking at it so please don’t merge.

Looks like my bug is unrelated, so please ignore me :slight_smile:

This pull request has been mentioned on Discourse Meta. There might be relevant details there:

That is what I found weird about this too. I suspect it has something to do with the fact that the redirect happens while the URL is loading.

I like the fix a lot, but agree with David here, it seems very odd to fix a bug by breaking a line :slight_smile:

If this is the only way to go about the fix I recommend a comment in the codebase that explains the oddity.

Any news about this @udan11?

I updated the PR with a more descriptive commit message and a code comment. As soon as I get your approval, I will merge it.

This pull request has been mentioned on Discourse Meta. There might be relevant details there: