Closed Fi1osof closed 5 years ago
Your input is invalid. %
may not be used literally, but has to be encoded as %25
.
segment() does not encode or decode the individual values. that's why you can read foo%foo
, but not write that (because it expects properly encoded values.
segmentCoded() on the other hand won't allow you to read the invalid value, but would allow you to write it.
Either way, you'll have to find a way to deal with invalid input.
So why i do not get error on uri = new URI("/foo/foo%foo"); ?
because it's not parsing the path content until you actually modify it.
Main example in offdoc:
// mutating URLs
URI("http://example.org/foo.html?hello=world")
.username("rodneyrehm")
// -> http://rodneyrehm@example.org/foo.html?hello=world
.username("")
// -> http://example.org/foo.html?hello=world
.directory("bar")
// -> http://example.org/bar/foo.html?hello=world
.suffix("xml")
// -> http://example.org/bar/foo.xml?hello=world
.query("")
// -> http://example.org/bar/foo.xml
.tld("com")
// -> http://example.com/bar/foo.xml
.query({ foo: "bar", hello: ["world", "mars"] });
// -> http://example.com/bar/foo.xml?foo=bar&hello=world&hello=mars
URI("http://example.org/foo%foo.html?hello=world") works too. Is this correct initializing?