-
Notifications
You must be signed in to change notification settings - Fork 4
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
I have updated this PR. It is now ready for review. |
@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. |
Closed the pull request to separate out the proposed changes to to-match-string.ts. Ill break this into two PRs. |
This PR is much larger than I anticipated. Beside the addition of the URL patterns, I made the following changes:
added atoms.ts for basic building blocks. Changed the hex-color pattern to use the atoms.
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:
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):
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.