Skip to content

fix: recognize ports on protocol-less hostnames#6

Open
codefix-patchflow[bot] wants to merge 1 commit into
masterfrom
codefix/2a6dba6b-url-returns-false-for-urls-like-some-hostname-90
Open

fix: recognize ports on protocol-less hostnames#6
codefix-patchflow[bot] wants to merge 1 commit into
masterfrom
codefix/2a6dba6b-url-returns-false-for-urls-like-some-hostname-90

Conversation

@codefix-patchflow

Copy link
Copy Markdown

What failed

isURL interpreted the hostname portion of my-3272-service:9000 as a URL protocol after the 13.15.20 protocol parsing change.

With require_tld: false and require_valid_protocol: false, the hostname was removed as if it were a scheme and validation returned false instead of true.

What changed

Treat a numeric component after the first colon as a port when the URL has no // protocol delimiter Continue rejecting that form when requireprotocol is enabled Add the reported my-3272-service:9000 input to the protocol-less URL regression cases

  • src/lib/isURL.js around line 113 (modified, +7/-1)
  • test/validators.test.js around line 499 (modified, +1/-0)

Why this works

The parser now leaves hostname:port intact for the existing host and port validation stages. Explicit protocols, non-numeric scheme components, authentication parsing, and port range validation retain their existing paths

Expected result

validator.isURL('my-3272-service:9000', { requiretld: false, requirevalidprotocol: false }) returns true

Patchflow did not run repository-local commands; the automated review gate checks the patch without assuming the project full runtime environment is available.

🔧 Fixed automatically by Patchflow — $1/fix · no fix, no fee

Automation details
  • Job ID: 2a6dba6b-0b65-4be4-9990-b3960b2caa8b
  • Repository: CDEN190/validator.js
  • Branch: codefix/2a6dba6b-url-returns-false-for-urls-like-some-hostname-90
  • Base branch: master
  • Reference command: None
  • Review gate: automated static review; repository-local commands were not executed.

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

Successfully merging this pull request may close these issues.

0 participants