This commit is contained in:
Pine Wu
2020-04-29 13:29:07 -07:00
parent 84fc970a24
commit ff1b513fbc
2 changed files with 9 additions and 0 deletions

View File

@@ -222,6 +222,10 @@ function pathMatches(open: string, rule: string) {
return true;
}
if (rule[rule.length - 1] === '/') {
rule = rule.slice(0, -1);
}
const openSegments = open.split('/');
const ruleSegments = rule.split('/');
for (let i = 0; i < ruleSegments.length; i++) {

View File

@@ -56,6 +56,11 @@ suite('Link protection domain matching', () => {
test('sub paths', () => {
linkAllowedByRules('https://x.org/foo', ['https://x.org/foo']);
linkAllowedByRules('https://x.org/foo/bar', ['https://x.org/foo']);
linkAllowedByRules('https://x.org/foo', ['https://x.org/foo/']);
linkAllowedByRules('https://x.org/foo/bar', ['https://x.org/foo/']);
linkAllowedByRules('https://x.org/foo', ['x.org/foo']);
linkAllowedByRules('https://x.org/foo', ['*.org/foo']);