Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2cba1bc

Browse files
birtleswheresrhys
authored andcommitted
fix: allow matching relative URLs
1 parent0c3c650 commit2cba1bc

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

‎packages/fetch-mock/src/RequestUtils.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export type NormalizedRequestOptions =
1717
exportfunctionhasCredentialsInUrl(url:string):boolean{
1818
consturlObject=newURL(
1919
url,
20-
protocolRelativeUrlRX.test(url) ?'http://dummy' :undefined,
20+
!absoluteUrlRX.test(url) ?'http://dummy' :undefined,
2121
);
2222
returnBoolean(urlObject.username||urlObject.password);
2323
}

‎packages/fetch-mock/src/__tests__/FetchMock/routing.test.js‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import{beforeEach,describe,expect,it,vi}from'vitest';
1+
import{afterEach,beforeEach,describe,expect,it,vi}from'vitest';
22
importfetchMockfrom'../../FetchMock';
33

44
describe('Routing',()=>{
@@ -250,4 +250,17 @@ describe('Routing', () => {
250250
expect(res.status).toEqual(200);
251251
});
252252
});
253+
254+
describe('relative routes',()=>{
255+
beforeEach(()=>{
256+
fm.config.allowRelativeUrls=true;
257+
});
258+
afterEach(()=>{
259+
fm.config.allowRelativeUrls=false;
260+
});
261+
it('allows handling relative routes',async()=>{
262+
fm.route('/relative/path',200);
263+
awaitfm.fetchHandler('/relative/path');
264+
});
265+
});
253266
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp