-
Notifications
You must be signed in to change notification settings - Fork 166
Support url_pattern_regex (one plugin for more sites) #54
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
Conversation
Useful to create a plugin that handles more websites (i.e abc.com, abc.de, abc.eu, etc) or similar.
|
Example usage to match abc.com, abc.de and abc.pl: |
|
What happens if both $url_pattern and $url_pattern_regex are set? I'd rather just have one $url_pattern that can be used to match both as regex and as non-regex. But first you would have to somehow detect whether $url_pattern contains regex or not and that can be tricky... |
|
I would write in the help file or readme that user should use $url_pattern or $url_pattern_regex (not both). An alternative option would be like this: What do you think? |
|
Why not just have it like this: The laziest way of accomplishing this is just to check the first character of $url_pattern. If it's /, then you have a regex pattern. |
|
I wrote 4 alternatives: Alternative 1: Alternative 2: Alternative 3: Alternative 4: I would vote for 3 because it allows user to use any special character on preg_match: ** May not be good for unicode domain names? ** Or 4 is fine too, but we need to write that user must use / character. What do you think? |
|
Option 3 would also match 'abc.com' even when it was intended to be a regular match... I would go with 4 because few people use delimiters other than '/'. It's a default regex deliminator on every tutorial online. |
|
Perfect, I have updated the PR with a new commit according to your request :) |
|
Yup, looks good to me now! |
Useful to create a plugin that handles more websites (i.e abc.com, abc.de, abc.eu, etc) or similar.