Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
char0n opened this issue Jun 3, 2024 · 1 comment
Open

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

char0n opened this issue Jun 3, 2024 · 1 comment

Comments

@char0n
Copy link
Member

char0n commented Jun 3, 2024

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
Copy link
Member Author

char0n commented Jun 3, 2024

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.

char0n added a commit that referenced this issue Jun 5, 2024
@char0n char0n closed this as completed Jun 5, 2024
char0n pushed a commit that referenced this issue Jun 5, 2024
## [1.5.2](v1.5.1...v1.5.2) (2024-06-05)

### Bug Fixes

* **resolve:** avoid encoding "[" and "]" characters ([#84](#84)) ([d533536](d533536)), closes [#81](#81)
@char0n char0n reopened this Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant