mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Use absolute URL when redirecting SVG sprite path.
This ensures that CDN URLs with relative paths do not end up losing the relative paths.
This commit is contained in:
parent
e81a98ec94
commit
9a7adcd178
@ -12,10 +12,10 @@ class SvgSpriteController < ApplicationController
|
|||||||
no_cookies
|
no_cookies
|
||||||
|
|
||||||
RailsMultisite::ConnectionManagement.with_hostname(params[:hostname]) do
|
RailsMultisite::ConnectionManagement.with_hostname(params[:hostname]) do
|
||||||
theme_id = params[:theme_id].to_i
|
theme_id = params[:theme_id].to_i if params[:theme_id].present?
|
||||||
|
|
||||||
if SvgSprite.version(theme_id) != params[:version]
|
if SvgSprite.version(theme_id) != params[:version]
|
||||||
return redirect_to path(SvgSprite.path(theme_id))
|
return redirect_to UrlHelper.absolute((SvgSprite.path(theme_id)))
|
||||||
end
|
end
|
||||||
|
|
||||||
svg_sprite = "window.__svg_sprite = #{SvgSprite.bundle(theme_id).inspect};"
|
svg_sprite = "window.__svg_sprite = #{SvgSprite.bundle(theme_id).inspect};"
|
||||||
|
@ -24,8 +24,17 @@ describe SvgSpriteController do
|
|||||||
random_hash = Digest::SHA1.hexdigest("somerandomstring")
|
random_hash = Digest::SHA1.hexdigest("somerandomstring")
|
||||||
get "/svg-sprite/#{Discourse.current_hostname}/svg--#{random_hash}.js"
|
get "/svg-sprite/#{Discourse.current_hostname}/svg--#{random_hash}.js"
|
||||||
|
|
||||||
expect(response.status).to eq(302)
|
expect(response).to redirect_to(
|
||||||
expect(response.location).to include(SvgSprite.version)
|
"/svg-sprite/test.localhost/svg--#{SvgSprite.version}.js"
|
||||||
|
)
|
||||||
|
|
||||||
|
set_cdn_url "//some-cdn.com/site"
|
||||||
|
|
||||||
|
get "/svg-sprite/#{Discourse.current_hostname}/svg--#{random_hash}.js"
|
||||||
|
|
||||||
|
expect(response).to redirect_to(
|
||||||
|
"https://some-cdn.com/site/svg-sprite/test.localhost/svg--#{SvgSprite.version}.js"
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user