Skip to content

Commit

Permalink
match fetch when called with a string object
Browse files Browse the repository at this point in the history
  • Loading branch information
wheresrhys committed Jun 15, 2024
1 parent ed508c9 commit 6c55149
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/request-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export function normalizeRequest(url, options, Request) {
}
if (
typeof url === 'string' ||
url instanceof String ||
// horrible URL object duck-typing
(typeof url === 'object' && 'href' in url)
) {
Expand Down
6 changes: 6 additions & 0 deletions test/specs/routing/url-matching.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ describe('url matching', () => {
expect(fm.calls(true).length).toEqual(2);
});

it('match string objects', async () => {
fm.mock('http://a.com/path', 200).catch();
await fm.fetchHandler(new String('http://a.com/path')); // eslint-disable-line no-new-wrappers
expect(fm.calls(true).length).toEqual(1);
});

it('match exact strings with relative url', async () => {
fm.mock('/path', 200).catch();
await fm.fetchHandler('/pat');
Expand Down

0 comments on commit 6c55149

Please sign in to comment.