Skip to content

Commit 213bbc4

Browse files
committed
Support full URLs with or without slashes.
1 parent 4cfebe5 commit 213bbc4

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

app/acme_app.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def self.instance
2020

2121
# rewrite HAL links to make them clickable in a browser
2222
use Rack::Rewrite do
23-
r302 %r{^(\/api\/\w*\/)(%7B|\{)?(.*)(%7D|\})$}, '$1'
23+
r302 %r{^([\/\w]*)(%7B|\{)?(.*)(%7D|\})$}, '$1'
2424
end
2525

2626
run Acme::App.new

spec/api/root_endpoint_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,9 @@ def app
3030
expect(last_response.status).to eq 302
3131
expect(last_response.headers['Location']).to eq '/api/splines/'
3232
end
33+
it 'rewrites encoded HAL links without a trailing slash to make them clickable' do
34+
get '/api/splines%7B?cursor,size%7D'
35+
expect(last_response.status).to eq 302
36+
expect(last_response.headers['Location']).to eq '/api/splines'
37+
end
3338
end

0 commit comments

Comments
 (0)