Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
Normalize it all
Browse files Browse the repository at this point in the history
  • Loading branch information
pencil committed Mar 20, 2014
1 parent 4010f96 commit f27f974
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 2 additions & 3 deletions app/models/casino/service_ticket.rb
Expand Up @@ -21,9 +21,8 @@ def self.cleanup_consumed_hard


def service=(service)
unencoded_service = Addressable::URI.unencode(service)
encoded_service = Addressable::URI.encode(unencoded_service)
super(encoded_service)
normalized_encoded_service = Addressable::URI.parse(service).normalize.to_str
super(normalized_encoded_service)
end


Expand Down
6 changes: 6 additions & 0 deletions spec/model/service_ticket_spec.rb
Expand Up @@ -140,5 +140,11 @@
unconsumed_ticket.service = unconsumed_ticket.service
unconsumed_ticket.service.should eq('https://example.org/this%20is%20a%20test/j%C3%B6.png')
end

it 'does correctly reencode slashes' do
unconsumed_ticket.service = 'https://example.com/login?os_destination=http%3A%2F%2Fexample.com%2Fdisplay%2FTesting%2F%3Fa%3D1%26b%3D2'
unconsumed_ticket.service = unconsumed_ticket.service
unconsumed_ticket.service.should eq('https://example.com/login?os_destination=http://example.com/display/Testing/?a=1%26b=2')
end
end
end

0 comments on commit f27f974

Please sign in to comment.