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

Regex not working correctly #933

Open
howdyAnkit opened this issue Mar 4, 2024 · 1 comment
Open

Regex not working correctly #933

howdyAnkit opened this issue Mar 4, 2024 · 1 comment

Comments

@howdyAnkit
Copy link

Regex entered webste Link not functioning properly
I created a new script and entered the website name in the mentioned area. After entering it I noticed even though the entered website is proper and regex tested against it was correct aswell. the plugin was not able to execute the script mentioned it is only working for a normal url and hence my script is impacting the other part of website which I wont like it to be working.

Url : https://xxx.websitename.com
Now the above url works fine but it's getting applied to each and every page instead based on the route

For Eg : I'd Like to execute a diff script for https://xxx.websitename.com/abc and similarly diff script for https://xxx.websitename.com/def

my only requirement was to execute the script for a specific page abc and diff scripts for other parts of route. i did tested my regex on the mentioned link it seems to be correct. i also tried a workaround by using the window.location.href to find the correct route and execute the script but onchange of routes it still dosent function properly the same script gets applied here aswell for def instead the script was for the abc.

Please let me know if theres any work around to fix this. id like to contribute if maybe someone can point out what part of code is causing this

@xcv58
Copy link
Owner

xcv58 commented Mar 4, 2024

i also tried a workaround by using the window.location.href to find the correct route and execute the script but onchange of routes it still dosent function properly the same script gets applied here aswell for def instead the script was for the ABC.

I just tested this .*github.com/xcv58 regex and it works as expected (has the xcv58 log on https://github.com/xcv58/Custom-JavaScript-for-Websites-2/blob/master/src/js/libs/index.tsx page but not https://github.com/).

image

Could you please double check your regex?

Please let me know if theres any work around to fix this. id like to contribute if maybe someone can point out what part of code is causing this

Here is the matching logic

return new RegExp(host.pattern).test(url.href)

You can see it's implement here and you can reproduce this locally by passing the regex and your href.

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

No branches or pull requests

2 participants