Giter Site home page Giter Site logo

Comments (3)

sporkmonger avatar sporkmonger commented on July 21, 2024

I've been thinking about introducing a sorted_query field, but I'm pretty sure that using this behavior by default in the === method would be a mistake.

If implemented, it would use the OAuth normalization algorithm.

from addressable.

mislav avatar mislav commented on July 21, 2024

You didn't say why you think this would be a mistake.

I wouldn't close this so soon. This bit me in Webmock; it's a library where you stub a HTTP response by defining a URL and then, when that URL is requested, it returns a fake response. It compares URLs with the === operator, but was failing in some tests because of inconsistent query values ordering. Inconsistent ordering originated from the fact that hashes in 1.8 are unordered, and query values were populated from params in a hash.

If I had to get around this issue without patching Addressable, I would have to either ensure that query values are of consistent ordering when I build URIs (this would require a rewrite of a lot of my code; for instance I couldn't use URI#query_values=() anymore) or I would have to patch Webmock to do a custom URL comparison. The latter 'solution' kinda defeats the purpose of using Addressable in the first place.

from addressable.

sporkmonger avatar sporkmonger commented on July 21, 2024

You should be able to use this form if you need order to be preserved:

[['key', 'value']]

Getting a consistent sort order is then as simple as:

{'key' => 'value'}.to_a

from addressable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.