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
Case insensitive redirects #9755
Conversation
Currently the redirect API doesn't return a 302, which is what I expect, but it does return 301 to the passed in URL (preserving case). I'm not sure why, this seems the standard behavior. |
Thanks will review asap 👍 |
On windows there are some issues running tests and the eslint configuration.
|
Hey! I am not sure about adding a new option 🤔 If we would allow passing the options in the e.g. |
Yeah that was the alternative thought I had.
Either use PCRE option inlining `from: "(?:i)^\\/ACTION\\/$"`
Or the JS synrax: `from: "/^\\/ACTION\\/$/i"`
But since there was already quite a bit of code manipulating the regex
(trailing slash, ^, $ etc), it was a more invasive change. Plus with all
the escaping it just looks really bad.
Another issue I had with it was whether you'd want other modifiers to work
as well. The inline syntax would suggest that could work. Separate property
would not.
Happy to take it in that direction though.
|
The latest version of my Blogger Importer now generates case insensitive links and can also generate lower-case links if needed. |
👍 |
I'll have a look if I can smurf this in that direction.
…On Mon, 30 Jul 2018, 17:21 Katharina Irrgang, ***@***.***> wrote:
Or the JS synrax: from: "/^\\/ACTION\\/$/i"
👍
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#9755 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AD-uS0L1nqC69UTEE99U4550_4jFr6BTks5uLyRkgaJpZM4VigMa>
.
|
Pushed the requested changes. It now uses the requested format. Dropped the parameter and updated the tests to reflect. |
Thanks @jessehouwing - will review asap. |
.gitattributes
Outdated
@@ -0,0 +1,2 @@ | |||
# enforce unix style line endings |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
@@ -27,6 +27,13 @@ _private.registerRoutes = function registerRoutes() { | |||
* - you define /my-blog-post-1/ as from property | |||
* - /my-blog-post-1 or /my-blog-post-1/ should work | |||
*/ | |||
|
|||
var options = ''; |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Rebased against master and incorporated comments. |
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.
LGTM 👍
@@ -27,6 +27,13 @@ _private.registerRoutes = function registerRoutes() { | |||
* - you define /my-blog-post-1/ as from property | |||
* - /my-blog-post-1 or /my-blog-post-1/ should work | |||
*/ | |||
|
|||
let options = ''; | |||
if (redirect.from.match(/\/.*\/i/)) { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Not sure what you mean with the last comment... Are you suggesting to drop the first forward slash? I didn't do that cause one may have a pattern that ends with /i and there would be no way to distinguish. That's why I did only the variant where both leading and trailing slash are present eg: /..../i |
No. I only was suggesting to match the url with "ends with" This PR needs a rebase again 😕 |
Right, just scanning for I did find a bug in the regex I used (it didn't use I can rewrite it as: |
Rebased. |
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.
LGTM - thanks so much :)
* master: (25 commits) Version bump to 2.1.4 Updated Ghost-Admin to 2.1.4 Version bump to 2.1.4-beta.1 Updated Ghost-Admin to 2.1.4-beta.1 Updated private-sites to not redirect to full urls Bumped ghost-ignition to version 2.9.6 Upgrading Casper to 2.6.3 Refactored url utility to generate multiple API version URLs (#9897) Added new endpoint to upload square profile images with dimension validation (#9862) Removed change frequency and priority fields from sitemap generator (#9771) 🎨Added case insensitive support for redirects (#9755) Refactored direct usages of api controllers Normalised how we require models Refactored how we require shared middlewares from web/ (#9893) Removed duplicate 'id' for User permittedOptions Updated permittedOptions to correctly call super Updated base model to remove extraAllowedProperties Extended uncapitalise unit tests (#9891) Removed `res.isAdmin` from admin express app (#9889) Refactored `web/middleware` and `web/utils` to `web/shared` (#9892) ...
While migrating from Blogger to Ghost I ran into the issue that Blogger is case-insensitive in a couple of places:
I've integrated Google Search Console with my current blog and I'm seeing all kinds of people hitting 404's due to them using urls in all-lower-case.
I've updated my Blogger2Ghost.NET application to generate redirects like these
But that's not really nice. This Pull request adds the ability to add case-insensitivity to the redirects.json format:
The
caseInsensitive
is a boolean option, it's optional and the default is to keep the current behavior. By addingcaseInsensitive=true
the redirect will be initialized with the "i" RegExp option.I've considered checking the start of the regex for
(?i:)
as well and settign the flag, which is the way for most regex flavors to set case insensitivity inline. But since that's not part of the JavaScript regexp standard, that may be confusing.This change is