Git Product home page Git Product logo

Comments (7)

willnorris avatar willnorris commented on September 27, 2024

I don't love the idea of reimplementing go's built-in url escaping logic. Is this lack of ~ escaping actually causing problems for you in practice? Do you have a server that's choking on the ~ character or something? Would it be sufficient to call strings.Replace to replace that character after encoding the query string?

from go-querystring.

asarkar avatar asarkar commented on September 27, 2024

From my post:

This is just one difference between the two RFCs, there are likely others that I've not looked into yet, which is why a naive approach of replacing ~ with %7E isn't the path I want to go down.

from go-querystring.

willnorris avatar willnorris commented on September 27, 2024

Thanks, I did see that. But I'm still curious if this is an actual problem or a theoretical problem. And also if less invasive solutions are adequate.

from go-querystring.

asarkar avatar asarkar commented on September 27, 2024

There is a real problem where the server can’t handle ~. The server won’t change because it follows RFC 1738, and nothing says it can’t.
I’m not sure what you mean by “less invasive solutions”, can you elaborate?

from go-querystring.

willnorris avatar willnorris commented on September 27, 2024

I’m not sure what you mean by “less invasive solutions”, can you elaborate?

Sure, happy to elaborate. I mean that this package is very small and very focused on converting structs into url.Values. We rely on the go stdlib for things like url encoding. The Go team apparently decided to follow RFC 3986 for their escaping rules (which certainly seems reasonable given that the rfc was published in 2005). This is the first I've ever heard of that being a problem (at least in connection with go-querystring). Which isn't to dismiss your use-case at all... just to say that it seems to be quite rare.

Supporting a different url escaping scheme would require reimplementing a non-trivial portion of the Go stdlib (looks to be mostly in escape and shouldEscape). That expands the scope, complexity, and maintenance burden of this package beyond what it was intended for. That's what I mean by invasive (sorry if that was a poor word choice).

go-querystring allows structs to implement the query.Encoder interface which should be sufficient for providing alternate escaping rules for those (seemingly) rare cases where it is needed.

from go-querystring.

willnorris avatar willnorris commented on September 27, 2024

Actually, I'm completely wrong! This escaping isn't happening inside go-querystring at all. It's happening as part of the values.Encode call which happens after go-querystring is done. So there's nothing we could change anyway. You'll need to find a different library that can take a url.Values and encode it using the RFC1738 escaping rules

from go-querystring.

asarkar avatar asarkar commented on September 27, 2024

ok, thanks for looking into it.

from go-querystring.

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.