-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Fix page redirect preview #2711
Conversation
It included '//' - this ought to fix #2380.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch! I've noted a cleaner method of implementing this change.
field_from = field_from_url.val(); | ||
field_to = field_to_url.val(); | ||
field_from_absolute = (field_from.length > 0) && (field_from[0] === "/"); | ||
field_to_absolute = (field_to.length > 0) && (field_to[0] === "/"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L27 + L28 are replicating field_to.startsWith()
etc
field_from_absolute = (field_from.length > 0) && (field_from[0] === "/"); | ||
field_to_absolute = (field_to.length > 0) && (field_to[0] === "/"); | ||
redirect_from = "/$lang/$version" + (field_from_absolute ? "" : "/") + field_from; | ||
redirect_target = "/$lang/$version" + (field_to_absolute ? "" : "/") + field_to; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conditional logic wouldn't be needed here if just using a simple regex to remove leading /
. For example:
redirect_from = "/$lang/$version/" + field_from_url.val().replace(/^\/+/, '')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. yes, that's much cleaner, I'll edit the PR accordingly. Thank you for the review.
It would be nice if this could be cleaned up an merged. Threw me off causing me almost half a day's work. |
@rixx hi, are you still interested on going with this PR? Would be awesome to got your contribution merged. |
@fenilgandhi That label isn't exclusive! We just tag some issues as easier. If you want to go through the backlog, I'm sure there are more issues you could fix. For now, I think this issue is already covered. |
Note: As the original author hasn't responded in almost a year, this PR could benefit from:
|
@vidartf If you'd like to do that, go ahead. :) |
It included '//' - this ought to fix #2380.