swaggerexpert / openapi-path-templating

OpenAPI Path Templating parser, validator and resolver.
Apache License 2.0
2 stars 0 forks source link

Make sure we're handling `[]` in special way #81

Closed char0n closed 1 month ago

char0n commented 1 month ago
encoded.replace(/%5B/g, '[').replace(/%5D/g, ']');

Ensuring that [ and ] are not percent-encoded is because these characters are part of the syntax used in IPv6 addresses within URIs. According to the URI standard (RFC 3986), these characters are allowed in the host component of a URI to enclose IPv6 addresses, and encoding them would break the correct representation of such addresses.

For example, an IPv6 address in a URL looks like this: http://[2001:db8::1]/. If [ and ] were percent-encoded, it would result in an incorrect URL: http://%5B2001:db8::1%5D/. Thus, these characters must remain unencoded to ensure valid URLs.

char0n commented 1 month ago

We're handling just path part of the URL. But new URL constructor is not encoding [] in the path part of the URL as well.