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

Appearance settings

Commit f412834

Browse filesBrowse files
anonrigdanielleadams
authored andcommitted
lib: support more attributes for early hint link
PR-URL: #44874 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 3bb764a commit f412834
Copy full SHA for f412834

File tree

Expand file treeCollapse file tree

2 files changed

+14
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-1
lines changed
Open diff view settings
Collapse file

‎lib/internal/validators.js‎

Copy file name to clipboardExpand all lines: lib/internal/validators.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ function validateUnion(value, name, union) {
441441
}
442442
}
443443

444-
const linkValueRegExp = /^(?:<[^>]*>;)\s*(?:rel=(")?[^;"]*\1;?)\s*(?:(?:as|anchor|title)=(")?[^;"]*\2)?$/;
444+
const linkValueRegExp = /^(?:<[^>]*>;)\s*(?:rel=(")?[^;"]*\1;?)\s*(?:(?:as|anchor|title|crossorigin|disabled|fetchpriority|rel|referrerpolicy)=(")?[^;"]*\2)?$/;
445445

446446
/**
447447
* @param {any} value
Collapse file

‎test/parallel/test-validators.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-validators.js
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const {
1212
validateString,
1313
validateInt32,
1414
validateUint32,
15+
validateLinkHeaderValue,
1516
} = require('internal/validators');
1617
const { MAX_SAFE_INTEGER, MIN_SAFE_INTEGER } = Number;
1718
const outOfRangeError = {
@@ -154,3 +155,15 @@ const invalidArgValueError = {
154155
code: 'ERR_INVALID_ARG_TYPE'
155156
}));
156157
}
158+
159+
{
160+
// validateLinkHeaderValue type validation.
161+
[
162+
['</styles.css>; rel=preload; as=style', '</styles.css>; rel=preload; as=style'],
163+
['</styles.css>; rel=preload; title=hello', '</styles.css>; rel=preload; title=hello'],
164+
['</styles.css>; rel=preload; crossorigin=hello', '</styles.css>; rel=preload; crossorigin=hello'],
165+
['</styles.css>; rel=preload; disabled=true', '</styles.css>; rel=preload; disabled=true'],
166+
['</styles.css>; rel=preload; fetchpriority=high', '</styles.css>; rel=preload; fetchpriority=high'],
167+
['</styles.css>; rel=preload; referrerpolicy=origin', '</styles.css>; rel=preload; referrerpolicy=origin'],
168+
].forEach(([value, expected]) => assert.strictEqual(validateLinkHeaderValue(value), expected));
169+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.