Update isLocalURL to include LAN addresses, .local domains, and hostn…#5973
Update isLocalURL to include LAN addresses, .local domains, and hostn…#5973cathaysia wants to merge 4 commits into
Conversation
38f05a1 to
c5cad4d
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5973 +/- ##
==========================================
+ Coverage 85.34% 85.35% +0.01%
==========================================
Files 318 318
Lines 31922 31947 +25
Branches 8834 8851 +17
==========================================
+ Hits 27244 27269 +25
Misses 4246 4246
Partials 432 432 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
canova
left a comment
There was a problem hiding this comment.
Thanks for the PR, adding some comments below.
7dcfd1c to
ee13e17
Compare
|
can this pr be merged? |
|
Hey @cathaysia, you need to re-request review when you've done working on the feedback. I'll do that for you now :) |
|
thanks |
| /^127\./.test(hostname) || // Loopback 127.0.0.0/8 | ||
| /^10\./.test(hostname) || // Private 10.0.0.0/8 | ||
| /^172\.(1[6-9]|2[0-9]|3[0-1])\./.test(hostname) || // Private 172.16.0.0/12 | ||
| /^192\.168\./.test(hostname) || // Private 192.168.0.0/16 | ||
| /^100\.(6[4-9]|[7-9][0-9]|1[0-1][0-9]|12[0-7])\./.test(hostname) || // CGNAT 100.64.0.0/10 | ||
| /^169\.254\./.test(hostname) || // Link-local 169.254.0.0/16 | ||
| /^198\.(1[8-9])\./.test(hostname) // Benchmark 198.18.0.0/15 |
There was a problem hiding this comment.
These match hostnames like:
192.168.1.1.foo.com
URL.hostname will happily return these host names. Please make sure that the host names are actually ipv4 addresses.
There was a problem hiding this comment.
I updated the regex, could you please check it again?
a76c6c5 to
1ae49e4
Compare


Treat non-public addresses—such as loopback addresses, LAN addresses, and CGNAT addresses—as local addresses; this allows for direct access to computers within the local network, Tailscale and etc..