mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
lib: support more attributes for early hint link
PR-URL: https://github.com/nodejs/node/pull/44874 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
@@ -441,7 +441,7 @@ function validateUnion(value, name, union) {
|
||||
}
|
||||
}
|
||||
|
||||
const linkValueRegExp = /^(?:<[^>]*>;)\s*(?:rel=(")?[^;"]*\1;?)\s*(?:(?:as|anchor|title)=(")?[^;"]*\2)?$/;
|
||||
const linkValueRegExp = /^(?:<[^>]*>;)\s*(?:rel=(")?[^;"]*\1;?)\s*(?:(?:as|anchor|title|crossorigin|disabled|fetchpriority|rel|referrerpolicy)=(")?[^;"]*\2)?$/;
|
||||
|
||||
/**
|
||||
* @param {any} value
|
||||
|
||||
@@ -12,6 +12,7 @@ const {
|
||||
validateString,
|
||||
validateInt32,
|
||||
validateUint32,
|
||||
validateLinkHeaderValue,
|
||||
} = require('internal/validators');
|
||||
const { MAX_SAFE_INTEGER, MIN_SAFE_INTEGER } = Number;
|
||||
const outOfRangeError = {
|
||||
@@ -154,3 +155,15 @@ const invalidArgValueError = {
|
||||
code: 'ERR_INVALID_ARG_TYPE'
|
||||
}));
|
||||
}
|
||||
|
||||
{
|
||||
// validateLinkHeaderValue type validation.
|
||||
[
|
||||
['</styles.css>; rel=preload; as=style', '</styles.css>; rel=preload; as=style'],
|
||||
['</styles.css>; rel=preload; title=hello', '</styles.css>; rel=preload; title=hello'],
|
||||
['</styles.css>; rel=preload; crossorigin=hello', '</styles.css>; rel=preload; crossorigin=hello'],
|
||||
['</styles.css>; rel=preload; disabled=true', '</styles.css>; rel=preload; disabled=true'],
|
||||
['</styles.css>; rel=preload; fetchpriority=high', '</styles.css>; rel=preload; fetchpriority=high'],
|
||||
['</styles.css>; rel=preload; referrerpolicy=origin', '</styles.css>; rel=preload; referrerpolicy=origin'],
|
||||
].forEach(([value, expected]) => assert.strictEqual(validateLinkHeaderValue(value), expected));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user