Skip to content

fix: allow protocol-less hostnames with numeric ports#3

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

fix: allow protocol-less hostnames with numeric ports#3
codefix-patchflow[bot] wants to merge 1 commit into
masterfrom
codefix/40af2795-url-returns-false-for-urls-like-some-hostname-90

Conversation

@codefix-patchflow

Copy link
Copy Markdown

What failed

isURL treated leading hostname: text as a protocol even when the text after the colon was a numeric port. For inputs such as my-3272-service:9000, this consumed the hostname before normal host and port parsing could validate it.

What changed

The protocol-disambiguation logic now recognizes host:port shapes when a protocol is not required and leaves them for the existing host and port parser. A regression case for my-3272-service:9000 was added to the protocol-less URL tests

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

Why this works

The existing parser already validates hostname syntax and numeric port ranges after protocol handling. Skipping protocol cleanup for numeric post-colon text lets my-3272-service remain the host and 9000 remain the port, while non-numeric protocol-like inputs still go through the protocol validation 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: 40af2795-19d1-472a-97d0-9677fe73d6f5
  • Repository: CDEN190/validator.js
  • Branch: codefix/40af2795-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