mirror of
https://github.com/kou029w/websri.git
synced 2025-01-18 16:08:16 +00:00
trims leading and trailing whitespace
This commit is contained in:
parent
ddcb93da0c
commit
5ad019029b
2 changed files with 4 additions and 5 deletions
|
@ -51,13 +51,12 @@ export class IntegrityMetadata implements IntegrityMetadataLike {
|
||||||
alg: PrioritizedHashAlgorithm;
|
alg: PrioritizedHashAlgorithm;
|
||||||
val: string;
|
val: string;
|
||||||
opt: string[];
|
opt: string[];
|
||||||
|
constructor(integrity: string | null | undefined) {
|
||||||
constructor(integrity: string) {
|
|
||||||
const {
|
const {
|
||||||
alg = "",
|
alg = "",
|
||||||
val = "",
|
val = "",
|
||||||
opt,
|
opt,
|
||||||
} = IntegrityMetadataRegex.exec(integrity)?.groups ?? {};
|
} = IntegrityMetadataRegex.exec((integrity ?? "").trim())?.groups ?? {};
|
||||||
|
|
||||||
Object.assign(this, {
|
Object.assign(this, {
|
||||||
alg,
|
alg,
|
||||||
|
|
|
@ -64,9 +64,9 @@ test.todo("accepts an IntegrityMetadata like object as input", function () {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.todo("trims leading and trailing whitespace", function () {
|
test("trims leading and trailing whitespace", function () {
|
||||||
const integrityMetadata = new IntegrityMetadata(
|
const integrityMetadata = new IntegrityMetadata(
|
||||||
"\t sha256-MV9b23bQeMQ7isAGTkoBZGErH853yGk0W/yUx1iU7dM=\u0020\u00a0\u1680\u180e\u2000\u2001\u2002\u3000",
|
"\t sha256-MV9b23bQeMQ7isAGTkoBZGErH853yGk0W/yUx1iU7dM=\u0020\u00a0\u1680\u2000\u2001\u2002\u3000",
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
|
|
Loading…
Add table
Reference in a new issue