Skip to content

fix: preserve no-protocol host:port URL parsing#5

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

fix: preserve no-protocol host:port URL parsing#5
codefix-patchflow[bot] wants to merge 1 commit into
masterfrom
codefix/8e89fa00-url-returns-false-for-urls-like-some-hostname-90

Conversation

@codefix-patchflow

Copy link
Copy Markdown

What failed

isURL treated a leading hostname: segment as a protocol whenever it matched the scheme regex. For values like my-3272-service:9000, that stripped the hostname and left 9000 to be validated as the host, causing validation to return false.

What changed

Left host:digits inputs intact for normal host/port parsing when requireprotocol is false Kept existing protocol handling for required-protocol URLs, explicit // protocols, authentication-like inputs, and non-port protocol payloads Added the reported my-3272-service:9000 case to the no-protocol URL regression tests

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

Why this works

When the text after the first colon is a numeric port and no protocol is required, the URL should be parsed as host:port rather than as protocol:path. The later port validator already enforces numeric port range rules, so this restores the expected path without bypassing existing host validation

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: 8e89fa00-edec-4bb7-94af-b1c3c4c0a6b6
  • Repository: CDEN190/validator.js
  • Branch: codefix/8e89fa00-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