Skip to content

Remove monkey patch from Addressable::URI#normalized_query so that it can be compatible with Addressable 2.8.2#50

Open
ericfirth wants to merge 1 commit into
postrank-labs:masterfrom
viewthespace:remove-address-normalized-query-monkey-patch
Open

Remove monkey patch from Addressable::URI#normalized_query so that it can be compatible with Addressable 2.8.2#50
ericfirth wants to merge 1 commit into
postrank-labs:masterfrom
viewthespace:remove-address-normalized-query-monkey-patch

Conversation

@ericfirth

Copy link
Copy Markdown

This fixes the error on #49

Removing the monkey patch entirely lead to the following error

/Users/eric.firth/.rbenv/versions/3.0.4/bin/ruby -I/Users/eric.firth/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/rspec-core-3.12.2/lib:/Users/eric.firth/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/rspec-support-3.12.1/lib /Users/eric.firth/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/rspec-core-3.12.2/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb
...........F...........................................................

Failures:

  1) PostRank::URI normalize cleans whitespace in PostRank::URIs
     Failure/Error: expect(n('http://igvita.com/a/../?  ')).to eq(igvita)

       expected: "http://igvita.com/"
            got: "http://igvita.com/?%20%20"

       (compared using ==)
     # ./spec/postrank-uri_spec.rb:77:in `block (3 levels) in <top (required)>'

Finished in 0.13964 seconds (files took 0.29346 seconds to load)
71 examples, 1 failure

Failed examples:

rspec ./spec/postrank-uri_spec.rb:76 # PostRank::URI normalize cleans whitespace in PostRank::URIs

So I split on whitespace and took the first item. I initially tried just stripping the URI as a string, but then got

     Failure/Error: expect(n('http://igvita.com/a/../? #test')).to eq(igvita)

       expected: "http://igvita.com/"
            got: "http://igvita.com/?%20"

Happy to make any changes needed.

jemminger pushed a commit to jemminger/postrank-uri that referenced this pull request Mar 12, 2026
…ibility

Remove the Addressable::URI#normalized_query monkey-patch that is
incompatible with addressable 2.8+. Instead, handle whitespace in URIs
by splitting on spaces in the normalize method.

Based on PR postrank-labs#50 by @ericboehs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant