Fix IPv6 localhost detection in tracker script #1200
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
The tracker script has logic that disables itself for localhost addresses, and seems to want to handle literal IPv6 addresses but does not do so correctly.
This the default for a few development setups, see for instance: https://github.com/shellscape/webpack-plugin-serve#usage
Spec of literals in urls: https://datatracker.ietf.org/doc/html/rfc2732
Behaviour of literals in practice in javascript:
Tested with current LTS node and in Firefox and Chromium. The browsers also redirect when a url in typed in the location bar.
Changes
IPv6 literals in url hostnames follow RFC 2732 so are enclosed in brackets.
Browsers normalise so matching zeros is not required.
Allow
::
unspecified address as well as::1
loopback address.Non-capturing groups not required when using
/.../.test()
method.Tests
Ideally would have some, there don't seem to be any for the tracker script?
Changelog
Maybe needs an entry? You tell me.
Documentation
This change does not need a documentation update.