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

Allow host name fuzzy matching for Compatibility URLs #680

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

restrict host fuzzy matching to subdomains

  • Loading branch information
christophertino committed Feb 9, 2021
commit 2c23b404d66145550a292c07888e7ad4ae885521
@@ -55,8 +55,8 @@ export function fuzzyUrlMatcher(url, urls) {
log(`[fuzzyUrlMatcher] host (${host}) and path (${path}) strict match`);
return true;
}
} else if (host.charAt(0) === '*') {
if (tab_host.endsWith(host.slice(1))) {
} else if (host.substr(0,2) == "*.") {
if (tab_host.endsWith(host.slice(2))) {
if (!path) {
log(`[fuzzyUrlMatcher] host (${host}) fuzzy match`);
return true;
@@ -159,9 +159,10 @@ describe('src/utils/matcher.js', () => {
'google.com',
'ghostery.com/products',
'example.com/page*',
'*atlassian.net',
'*twitter.com/ghostery',
'*jira.net/board*',
'*.atlassian.net',
'*.twitter.com/ghostery',
'*.jira.net/board*',
'*facebook.com',
];

test('host strict match', () => {
@@ -181,6 +182,11 @@ describe('src/utils/matcher.js', () => {
expect(fuzzyUrlMatcher('https://ghostery.atlassian.com', urls)).toBeFalsy();
});

test('host fuzzy match rules require \'.\' ', () => {
expect(fuzzyUrlMatcher('https://something.facebook.com', urls)).toBeFalsy();
expect(fuzzyUrlMatcher('https://facebook.com', urls)).toBeFalsy();
});

test('host fuzzy match and path strict match', () => {
expect(fuzzyUrlMatcher('https://page.twitter.com/ghostery', urls)).toBeTruthy();
expect(fuzzyUrlMatcher('https://page.twitter.com/ghostery2', urls)).toBeFalsy();
ProTip! Use n and p to navigate between commits in a pull request.