Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix notations of loopback addresses
127.0.0.1/8 refers to only a single IPv4 address "127.0.0.1" that have
the subnet mask 255.255.255.0, but doesn't to 127.0.0.2.
127.0.0.0/8, which is the exact definition of the loopback addresses
[1][2], includes what the regex says (127.0.0.0-127.255.255.255).

[1] https://tools.ietf.org/html/rfc1122
[2] https://tools.ietf.org/html/rfc6890
  • Loading branch information
wataash committed Aug 4, 2019
commit db5809bdd2a556f4fa3771430a5a986d5411bbc9
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const isLocalhost = Boolean(
window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.1/8 is considered localhost for IPv4.
// 127.0.0.0/8 are considered localhost for IPv4.
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
)
Expand Down
2 changes: 1 addition & 1 deletion packages/react-scripts/template/src/serviceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const isLocalhost = Boolean(
window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.1/8 is considered localhost for IPv4.
// 127.0.0.0/8 are considered localhost for IPv4.
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
)
Expand Down