-
Notifications
You must be signed in to change notification settings - Fork 6
add more edge cases for URLs #166
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
base: main
Are you sure you want to change the base?
Conversation
'+' in a URL works; '@' for user names does not
| "(?<port>\\d+))?(?<path>/[^#?]*)?(?<query>\\?" | ||
| "((?<userColon>:)(?<password>\\w+))?(?<at>@))?" | ||
| "(?<host>[^:/]+)((?<portColon>:)(?<port>\\d+))?" | ||
| "(?<path>/[^#?]*)?(?<query>\\?" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link to test: https://regex101.com/r/n7KVRu/1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This (?<host>[^:\/]+) implicitly allows any characters. Maybe this should be constrained to alphanumerics (i.e. (?<host>[a-zA-Z0-9-.]+))?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this doesn’t matter, because the host is later on (in the loop) restricted to [NSCharacterSet URLHostAllowedCharacterSet].
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link to test
I've made the user group optional in the regex, and if not set, 8e32b64 will now remove the @ altogether. Added another test for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have used this one in one of my projects, in case you want to look at another approach: https://regex101.com/r/bsN8uj/5
|
Hmm, what about IDNs? Sigh. |



Uh oh!
There was an error while loading. Please reload this page.