Set S3 redirect metadata when processing redirect files#5
Conversation
Modify redirect location header if no leading / on S3 upload
|
@tomislacker Sorry, I'm not the maintainer of this project so I can't help. |
|
Hi, looking over this now. |
| opts[:content_type] = response['content-type'] rescue "text/html" | ||
|
|
||
| # Detect a meta-redirect and set an S3 hosting redirect metadata item | ||
| if response =~ /META http-equiv='refresh' content='0;URL="(.*)"/ |
There was a problem hiding this comment.
I think there are likely some common cases where this regex would fail. For example:
<meta http-equiv="refresh" content="0;url=http://example.com" />
or
<meta http-equiv="refresh" content="2;url='http://example.com'" />
I'll merge this request and then likely modify this to catch a wider range of meta redirects.
There was a problem hiding this comment.
Oh I see, my bad, this is just a little hack to use the existing process_redirect. Got it! :)
| # Detect a meta-redirect and set an S3 hosting redirect metadata item | ||
| if response =~ /META http-equiv='refresh' content='0;URL="(.*)"/ | ||
| location = $1 | ||
| if location =~ /^(?:[^\/]|http:\/\/|https\:\/\/).*/ |
There was a problem hiding this comment.
This is prepending a slash if the location starts with http or https, is that needed for s3 redirects? Also wouldn't this redirect to the wrong place if the location is not absolute. So if we are at http://www.google.com/section/page1 and that page has a meta refresh to url='page2' then this would redirect to /page2 instead of /section/page2.
No description provided.