Hi Spencer, thanks for the proposal. My main question is what happens if the URI already has a query. Do we update it? Do we replace it? On this question alone, if we were to add such functionality, then I think it should not be called encode_query but rather update_query/replace_query.
update_query itself has ambiguous connotations as well, in that it can either update_query (replacing duplicate keys) or simply append to it since a query can have duplicate keys (so maybe it should be called append_query?). Note how a web server will handle duplicate keys is completely up to the web server implementation, so having an implementation that appends by default can lead to surprising behaviour. The implementation of the PR follows the append_query semantics - but we need to discuss all of those things if we are to accept such a proposal because these semantics need to make sense in the general case. The other thing to note is that "URI.encode_query" is one of many ways of encoding a query string. Web applications have historically built more complex query encoding/decoding schemas that (poorly) support richer data structure, so this API may not be enough depending on what you want to encode. On Fri, Nov 6, 2020 at 1:18 PM Bruce Tate <[email protected]> wrote: > I think the pull request is a much better API. It both takes and returns a > URI, and also gains type checking benefits (and readability benefits... > single level of abstraction). > > -bt > > On Fri, Nov 6, 2020 at 3:16 AM Andrea Leopardi <[email protected]> > wrote: > >> Hey Spencer, >> >> Considering how concise the snippet of code you showed is even without >> URI.encode_query/2, I think the value of having a smaller API surface is >> higher than the value of adding a function that you can replace with just a >> few more characters. Thoughts? >> >> On Thu, Nov 5, 2020 at 7:28 PM [email protected] < >> [email protected]> wrote: >> >>> I would like to propose the addition of URI.encode_query/2 to the URI >>> module to facilitate URI construction in a pipe friendly fashion. >>> >>> Here is an example MR on my fork of elixir >>> https://github.com/spencerdcarlson/elixir/pull/2 >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "elixir-lang-core" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/elixir-lang-core/7e297574-b4d0-4b03-8279-4abe50c191e0n%40googlegroups.com >>> <https://groups.google.com/d/msgid/elixir-lang-core/7e297574-b4d0-4b03-8279-4abe50c191e0n%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "elixir-lang-core" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/elixir-lang-core/CAM9Rf%2BKkTGR%3DG2bRApfhr51XD8RHr1HbZZg-Ef%3DJ8rb5aOOR5A%40mail.gmail.com >> <https://groups.google.com/d/msgid/elixir-lang-core/CAM9Rf%2BKkTGR%3DG2bRApfhr51XD8RHr1HbZZg-Ef%3DJ8rb5aOOR5A%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > > > -- > > Regards, > Bruce Tate > CEO > > > <https://bowtie.mailbutler.io/tracking/hit/f8218219-d2a8-4de4-9fef-1cdde6e723f6/c7c97460-016e-45fb-a4ab-0a70318c7b97> > > Groxio, LLC. > 512.799.9366 > [email protected] > grox.io > > -- > You received this message because you are subscribed to the Google Groups > "elixir-lang-core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elixir-lang-core/CAFXvW-4KRBnv3VLO3S6OSBSgLOHOKKohgee%3DqPo5ZZFxVfs1LA%40mail.gmail.com > <https://groups.google.com/d/msgid/elixir-lang-core/CAFXvW-4KRBnv3VLO3S6OSBSgLOHOKKohgee%3DqPo5ZZFxVfs1LA%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4JxNRZAz8S3SgErkZH8cYE_qmbDForrEdfA9LAM7jv_ZQ%40mail.gmail.com.
