This repository has been archived by the owner on Jul 13, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
URLGenerator should disregard a ? which isn't followed by an =
In some case, we seriously don't want to prepend the timestamp with & if there wasn't a query string there. If the original URL doesn't have any query string, we should add the ?.
- Loading branch information
Showing
2 changed files
with
4 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
|
@@ -38,7 +38,7 @@ def most_appropriate_url | ||
|
|
||
def timestamp_as_needed(url, options) | def timestamp_as_needed(url, options) | ||
if options[:timestamp] && timestamp_possible? | if options[:timestamp] && timestamp_possible? | ||
delimiter_char = url.include?('?') ? '&' : '?' | delimiter_char = url.match(/\?.+=/) ? '&' : '?' | ||
"#{url}#{delimiter_char}#{@attachment.updated_at.to_s}" | "#{url}#{delimiter_char}#{@attachment.updated_at.to_s}" | ||
else | else | ||
url | url | ||
|
@@ -58,7 +58,7 @@ def escape_url_as_needed(url, options) | ||
end | end | ||
|
|
||
def escape_url(url) | def escape_url(url) | ||
url.respond_to?(:escape) ? url.escape : URI.escape(url) | (url.respond_to?(:escape) ? url.escape : URI.escape(url)).gsub(/(\/.+)\?(.+\.)/, '\1%3F\2') | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
metaskills
Contributor
|
|||
end | end | ||
end | end | ||
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This line means I can no longer have a URL from an interpolation look like so, note the ? for the params. I have worked around the issue by defining a singleton method for #escape on the returned string. The subject of the commit seems to indicated this should not happen since indeed my returned URL does have an = after it.
So is this pattern what we need to do in my case of returning a self build url in an interpolation?