Skip to content

Commit 1f02f85

Browse files
Bayheckadil.rakhaliyev
andauthored
fix: url match fixed (#3064)
* fix: url match fixed * test: test added for fixed match url --------- Co-authored-by: adil.rakhaliyev <[email protected]>
1 parent d35f993 commit 1f02f85

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/request-pipeline/request-hooks/request-is-match-rule.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ function matchUrl (optionValue: any, checkedValue: any): boolean {
1313
return true;
1414

1515
if (typeof optionValue === 'string') {
16-
optionValue = ensureOriginTrailingSlash(optionValue);
16+
optionValue = ensureOriginTrailingSlash(optionValue);
17+
checkedValue = ensureOriginTrailingSlash(checkedValue);
1718

1819
return optionValue === checkedValue;
1920
}

test/server/request-hook-test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,13 @@ describe('Request is match rule', async () => {
378378
});
379379
});
380380

381+
it('Origin trailing slash normalization', async () => {
382+
const rule = new RequestFilterRule('http://example.com/');
383+
const requestInfo = { url: 'http://example.com' };
384+
385+
expect(await requestIsMatchRule(rule, requestInfo)).to.be.true;
386+
});
387+
381388
it('RequestFilterRule.ANY', async () => {
382389
expect(await requestIsMatchRule(RequestFilterRule.ANY, { url: 'https://example.com' })).to.be.true;
383390
expect(await requestIsMatchRule(RequestFilterRule.ANY, { url: 'https://example.com/index.html' })).to.be.true;

0 commit comments

Comments
 (0)