forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
url: reuse existing context in href setter
Correctness-wise, this removes side effects in the href setter if parsing fails. Style-wise, this allows removing the parse() wrapper function around C++ _parse(). Also fix an existing bug with whitespace trimming in C++ that was previously circumvented by additionally trimming the input in JavaScript. Fixes: nodejs#24345 Refs: nodejs#24218 (comment)
- Loading branch information
Showing
3 changed files
with
31 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1375,6 +1375,7 @@ void URL::Parse(const char* input, | |
else | ||
break; | ||
} | ||
input = p; | ||
len = end - p; | ||
} | ||
|
||
|
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,15 @@ | ||
'use strict'; | ||
|
||
// Tests below are not from WPT. | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
|
||
const ref = new URL('http://example.com/path'); | ||
const url = new URL('http://example.com/path'); | ||
common.expectsError(() => { | ||
url.href = ''; | ||
}, { | ||
type: TypeError | ||
}); | ||
|
||
assert.deepStrictEqual(url, ref); |