Skip to content

fix valid_url?/1 accepting stray digits between TLD and port#19

Merged
jaimeiniesta merged 1 commit into
masterfrom
fix-15
May 4, 2026
Merged

fix valid_url?/1 accepting stray digits between TLD and port#19
jaimeiniesta merged 1 commit into
masterfrom
fix-15

Conversation

@jaimeiniesta

@jaimeiniesta jaimeiniesta commented May 4, 2026

Copy link
Copy Markdown
Owner

The leading ([0-9]{1,5})? group in @url_regexp accepted bare digits glued onto the TLD, so URLs like https://example.com8080 and https://example.com12345/path matched. The group had no purpose — real ports must be preceded by :, already covered by (:(\d{1,5}))?.

Fixes #18

The leading ([0-9]{1,5})? group in @url_regexp accepted bare digits
glued onto the TLD, so URLs like `https://example.com8080` and
`https://example.com12345/path` matched. The group had no purpose —
real ports must be preceded by `:`, already covered by (:(\d{1,5}))?.
Drop it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Funkspector.Utils.valid_url?/1 so it no longer accepts URLs with stray digits appended directly after the TLD (e.g., https://example.com8080) by tightening the URL regexp and adding regression tests.

Changes:

  • Remove an unused digit-matching group in @url_regexp that allowed digits between the TLD and the optional port/path.
  • Add tests asserting such “TLD+digits” URLs are rejected.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
test/utils_test.exs Adds regression tests for invalid URLs with stray digits after the TLD.
lib/funkspector/utils.ex Updates @url_regexp to require ports to be preceded by : and disallow glued-on digits after the TLD.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/funkspector/utils.ex
@jaimeiniesta
jaimeiniesta merged commit bbc2954 into master May 4, 2026
18 checks passed
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.

valid_url?/1 regex permits stray digits between TLD and :port

2 participants