Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: new Request has consider second argument (#411)
* refactor: write as constant * refactor(test): avoid async if no needed * test: add second argument check * fix: duplex half once * Create large-dancers-stare.md
- Loading branch information
Showing
5 changed files
with
31 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@edge-runtime/primitives": patch | ||
"edge-runtime": patch | ||
"@edge-runtime/vm": patch | ||
--- | ||
|
||
fix: new Request has consider second argument |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,43 @@ | ||
/** | ||
* @jest-environment ../jest-environment/dist | ||
*/ | ||
test('evaluate promise', async () => { | ||
test('evaluate promise', () => { | ||
const url = 'https://vercel.com/foo/bar?one=value' | ||
const req = new Request(url) | ||
expect(req.url).toEqual(url) | ||
}) | ||
|
||
test('parses and reconstructs the URL alone', async () => { | ||
test('parses and reconstructs the URL alone', () => { | ||
const url = 'https://vercel.com/foo/bar?one=value' | ||
const req = new Request(url) | ||
expect(req.url).toEqual(url) | ||
}) | ||
|
||
test('throws when the URL is malformed', async () => { | ||
test('throws when the URL is malformed', () => { | ||
try { | ||
void new Request('meeeh') | ||
} catch (error: any) { | ||
expect(error.message).toEqual('Failed to parse URL from meeeh') | ||
} | ||
}) | ||
|
||
test('Request.referrer is `about:client` by default', async () => { | ||
test('Request.referrer is `about:client` by default', () => { | ||
const request = new Request('https://example.vercel.sh') | ||
expect(request.referrer).toEqual('about:client') | ||
}) | ||
|
||
test('Request.referrer can be customized', async () => { | ||
test('Request.referrer can be customized', () => { | ||
const request = new Request('https://example.vercel.sh', { | ||
referrer: 'https://vercel.com/home', | ||
}) | ||
expect(request.referrer).toEqual('https://vercel.com/home') | ||
}) | ||
|
||
test('create a Request instance using second argument', () => { | ||
expect( | ||
new Request( | ||
'https://example.vercel.sh', | ||
new Request('https://example.vercel.sh', { method: 'POST' }) | ||
).method | ||
).toBe('POST') | ||
}) |
91b4abd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
edge-runtime – ./
edge-runtime.vercel.app
edge-runtime-git-main.vercel.sh
edge-runtime.vercel.sh