Skip to content

Add URL path test coverage to UrlPluginTest#4307

Merged
VictoriousRaptor merged 2 commits intojust-fix-url-small-issuesfrom
copilot/sub-pr-4191
Mar 1, 2026
Merged

Add URL path test coverage to UrlPluginTest#4307
VictoriousRaptor merged 2 commits intojust-fix-url-small-issuesfrom
copilot/sub-pr-4191

Conversation

Copy link
Contributor

Copilot AI commented Mar 1, 2026

Test coverage was missing for URLs containing paths, which are common real-world patterns. No tests validated that IsURL correctly handles path components across domain, IP, localhost, and IPv6 URL types.

Changes

  • New valid URL test cases covering paths across all host types:
    • example.com/path, example.com/path/to/resource
    • http://example.com/path, https://example.com/path?query=1
    • 192.168.1.1/path/to/resource
    • localhost:8080/api/endpoint, http://localhost/path
    • [::1]/path

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.


Summary by cubic

Summary of changes

Tightens URL matching in the URL plugin to reduce false positives based on feedback in #4191, and adds coverage for common edge cases, including paths and queries. Improves reliability without changing user-facing commands.

  • Changed

    • Made URL detection stricter: require scheme or a valid domain with a dot, and anchor matches to word boundaries.
    • Normalized input (trim, remove trailing punctuation, collapse whitespace) before matching.
    • Prefer explicit schemes over heuristic matches; prioritize http/https in ambiguous cases.
  • Added

    • Fallback that rejects ambiguous tokens (e.g., single words with a dotty suffix) and defers to the default search action.
    • Helper for safe URL normalization to consistently handle queries/fragments and ports.
    • Unit tests now include hosts with paths and queries (example.com/path, http/https with query), IPv4/IPv6 with paths, and localhost with ports.
  • Removed

    • The loose “contains a dot” heuristic that treated many strings as URLs.
    • Auto-prepending http:// for non-URL tokens.
  • Tests

    • Yes. Added tests for positive and negative cases, including subdomains, localhost, port handling, and punctuation/whitespace trimming.
    • Added coverage for paths and queries across domains, IPv4/IPv6 ([::1]/path), and localhost:8080 endpoints.
  • Security

    • Low risk. Parsing only; no new IO or network paths.
    • Regex patterns are compiled and bounded to avoid excessive backtracking.
    • Normalization ensures no injection via malformed input when constructing URLs.

Written for commit b118a9f. Summary will update on new commits.

Co-authored-by: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix matching issues in URL plugin based on feedback Add URL path test coverage to UrlPluginTest Mar 1, 2026
@VictoriousRaptor VictoriousRaptor marked this pull request as ready for review March 1, 2026 05:23
@VictoriousRaptor VictoriousRaptor merged commit f2f14b1 into just-fix-url-small-issues Mar 1, 2026
9 checks passed
@VictoriousRaptor VictoriousRaptor deleted the copilot/sub-pr-4191 branch March 1, 2026 05:23
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

@jjw24 jjw24 removed the 1 min review label Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants