-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Use node 7+ WHATWG parser for hostname, fixes #1002 * only use URL if host is IPv6, expose parsed URL * catch invalid URLs, memoize empty obj * hostname returns empty string when URL throws
- Loading branch information
1 parent
0125878
commit 327b65c
Showing
5 changed files
with
91 additions
and
0 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
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
'use strict'; | ||
|
||
const request = require('../helpers/context').request; | ||
const assert = require('assert'); | ||
|
||
describe('req.URL', () => { | ||
describe('should not throw when', () => { | ||
it('host is void', () => { | ||
const req = request(); | ||
assert.doesNotThrow(() => req.URL, TypeError); | ||
}); | ||
|
||
it('header.host is invalid', () => { | ||
const req = request(); | ||
req.header.host = 'invalid host'; | ||
assert.doesNotThrow(() => req.URL, TypeError); | ||
}); | ||
}); | ||
|
||
it('should return empty object when invalid', () => { | ||
const req = request(); | ||
req.header.host = 'invalid host'; | ||
assert.deepStrictEqual(req.URL, Object.create(null)); | ||
}); | ||
}); |