Skip to content

fix: allow hostname ports without protocol#4

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

fix: allow hostname ports without protocol#4
codefix-patchflow[bot] wants to merge 1 commit into
masterfrom
codefix/9c19a7f8-url-returns-false-for-urls-like-some-hostname-90

Conversation

@codefix-patchflow

Copy link
Copy Markdown

What failed

isURL treated values like my-3272-service:9000 as an explicit protocol because the protocol-detection regex consumed the leading my-3272-service: token before host and port parsing could run.

What changed

Added a host-with-port disambiguation check for protocol-like prefixes without // or auth data. When the prefix is a valid host and the suffix is a valid numeric port, isURL now leaves the string intact for the existing hostname and port parser Added the reported my-3272-service:9000 regression case to the no-protocol URL tests

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

Why this works

The new check only applies when a protocol is not required, the text after the colon is a valid port, and the text before the colon is accepted as an IP, FQDN, or whitelisted host. Non-numeric scheme bodies such as custom:something and malicious protocol payloads continue through the explicit protocol path

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: 9c19a7f8-6233-435a-b4ae-913b1f2fbc85
  • Repository: CDEN190/validator.js
  • Branch: codefix/9c19a7f8-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