[Fix] nvm_get_mirror: fix awk URL validation to actually reject invalid URLs

The awk expression `$0 ~ "regex"` as a bare statement in the action block evaluates the match but doesn't affect the exit code.
awk always prints the line and exits 0, making the validation a no-op.

Bug introduced in b1fa143dd8.
This commit is contained in:
Jordan Harband
2026-03-14 09:40:43 -07:00
parent a937cb595e
commit 3c48015986
2 changed files with 7 additions and 1 deletions

View File

@@ -46,3 +46,9 @@ testMirrors '`do something bad`'
testMirrors 'https://nodejs.org/dist; xdg-open http://www.google.com;'
testMirrors 'https://nodejs.org/dist&&xdg-open http://www.google.com;'
testMirrors 'https://nodejs.org/dist|xdg-open http://www.google.com;'
# Test that awk URL validation rejects non-URL values
testMirrors 'not a url'
testMirrors 'ftp://wrong-scheme'
testMirrors 'http://'
testMirrors 'javascript:alert(1)'