Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add patterns for matching URLs and URL components #79

Closed
wants to merge 22 commits into from

Conversation

PaulJPhilp
Copy link
Contributor

@PaulJPhilp PaulJPhilp commented Apr 1, 2024

This PR is much larger than I anticipated. Beside the addition of the URL patterns, I made the following changes:

  1. added atoms.ts for basic building blocks. Changed the hex-color pattern to use the atoms.

  2. changed toMatchString in test-utils to address issue [Bug]test-utils/ts-match-string doesn't work with trailing lookaheads. #81 . toMatchString now support 3 use cases:

    • match the exact string passed in
    • match any substring of the string passed in
    • match an exact substring of the string passed in
  3. updated all the test cases to use the proposed change to the toMatchString API.

Please reach out to me if you have any questions.

Summary

This PR adds a URL matcher to the pattern library. The URL pattern can be used to match arbitrarily complex Web URLs as defined in this wikipedia article: based on the #RFC 1738 standard (https://datatracker.ietf.org/doc/html/rfc1738).

Besides the primary pattern url, this pattern also publishes regular expressions for the following URL subcomponents (see above article):

  • urlScheme
  • urlAuthority
  • urlPath
  • urlQuery
  • urlFragment

as well as validation and finder helpers.

As well as the URL pattern, this PR adds a building blocks library called atoms (e.g. uppercase, lowercase, alphabetical, hexDigit). The hex-color pattern has been updated to use the atoms pattern library.

Test plan

There is a test suite for each URL subcomponent (scheme, authority, path, query, fragment) as well as the primary pattern: url.

As well, a test suite to test the patterns in the atoms collections.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (65022ee) to head (b60eca6).

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #79   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           16        19    +3     
  Lines          183       255   +72     
  Branches        41        41           
=========================================
+ Hits           183       255   +72     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@PaulJPhilp
Copy link
Contributor Author

I have updated this PR. It is now ready for review.

@mdjastrzebski
Copy link
Member

@PaulJPhilp thank you for submitting this 👍 Head up that might not be able to review it promptly due to other obligations. I plan to review it during next two weeks.

@PaulJPhilp PaulJPhilp closed this Apr 19, 2024
@PaulJPhilp
Copy link
Contributor Author

Closed the pull request to separate out the proposed changes to to-match-string.ts. Ill break this into two PRs.

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.

3 participants