mirror of
https://github.com/kou029w/websri.git
synced 2025-01-18 08:05:13 +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;
|
||||
val: string;
|
||||
opt: string[];
|
||||
|
||||
constructor(integrity: string) {
|
||||
constructor(integrity: string | null | undefined) {
|
||||
const {
|
||||
alg = "",
|
||||
val = "",
|
||||
opt,
|
||||
} = IntegrityMetadataRegex.exec(integrity)?.groups ?? {};
|
||||
} = IntegrityMetadataRegex.exec((integrity ?? "").trim())?.groups ?? {};
|
||||
|
||||
Object.assign(this, {
|
||||
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(
|
||||
"\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(
|
||||
|
|
Loading…
Add table
Reference in a new issue