aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParker Moore <parkrmoore@gmail.com>2014-03-03 22:07:48 -0500
committerParker Moore <parkrmoore@gmail.com>2014-03-03 22:07:48 -0500
commitb86880352b421ad8884355ba2e2dea9b92c65996 (patch)
treef43be9edb81f5131026b25e2caba60c0639017c6
parent0ead88e6c2f26441e200a1a1132fb1a90225b854 (diff)
parenta66e031166183fde3cccfc0808aff447d5b0157a (diff)
downloadmy_new_personal_website-b86880352b421ad8884355ba2e2dea9b92c65996.tar.xz
my_new_personal_website-b86880352b421ad8884355ba2e2dea9b92c65996.zip
Merge pull request #1506 from duckpuppy/handle-multiple-redirects
gist_plugin: Handle multiple redirects, stopping if we find a circular r...
Diffstat (limited to '')
-rw-r--r--plugins/gist_tag.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/plugins/gist_tag.rb b/plugins/gist_tag.rb
index 9bdd14dc..61a9cc1e 100644
--- a/plugins/gist_tag.rb
+++ b/plugins/gist_tag.rb
@@ -78,8 +78,11 @@ module Jekyll
gist_url = get_gist_url_for(gist, file)
data = get_web_content(gist_url)
- if data.code.to_i == 302
+ locations = Array.new
+ while (data.code.to_i == 301 || data.code.to_i == 302)
data = handle_gist_redirecting(data)
+ break if locations.include? data.header['Location']
+ locations << data.header['Location']
end
if data.code.to_i != 200
@@ -95,6 +98,7 @@ module Jekyll
if redirected_url.nil? || redirected_url.empty?
raise ArgumentError, "GitHub replied with a 302 but didn't provide a location in the response headers."
end
+
get_web_content(redirected_url)
end