mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
ensure forward slash
This commit is contained in:
parent
a5fdbfe4a7
commit
bb44965c8e
2 changed files with 12 additions and 0 deletions
|
@ -52,4 +52,13 @@ describe PurgeCacheWorker do
|
||||||
|
|
||||||
assert_requested :get, url
|
assert_requested :get, url
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'works without forward slash' do
|
||||||
|
stub_request(:get, "http://#{@test_ip}/:cache/purge/test.jpg").
|
||||||
|
with(headers: {'Host' => 'kyledrake.neocities.org'})
|
||||||
|
.to_return(status: 200)
|
||||||
|
|
||||||
|
worker = PurgeCacheWorker.new
|
||||||
|
worker.perform @test_ip, 'kyledrake', 'test.jpg'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,6 +10,9 @@ class PurgeCacheWorker
|
||||||
end
|
end
|
||||||
|
|
||||||
def perform(proxy_ip, username, path)
|
def perform(proxy_ip, username, path)
|
||||||
|
# Must always have a forward slash
|
||||||
|
path = '/' + path if path[0] != '/'
|
||||||
|
|
||||||
url = Addressable::URI.encode_component(
|
url = Addressable::URI.encode_component(
|
||||||
"http://#{proxy_ip}/:cache/purge#{path}",
|
"http://#{proxy_ip}/:cache/purge#{path}",
|
||||||
Addressable::URI::CharacterClasses::QUERY
|
Addressable::URI::CharacterClasses::QUERY
|
||||||
|
|
Loading…
Add table
Reference in a new issue