mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 00:33:44 +00:00
Handle null in utils
This commit is contained in:
@@ -70,4 +70,10 @@ describe("Utils Service", () => {
|
|||||||
expect(Utils.newGuid()).toMatch(validGuid);
|
expect(Utils.newGuid()).toMatch(validGuid);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("fromByteStringToArray", () => {
|
||||||
|
it("should handle null", () => {
|
||||||
|
expect(Utils.fromByteStringToArray(null)).toEqual(null);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -97,6 +97,9 @@ export class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static fromByteStringToArray(str: string): Uint8Array {
|
static fromByteStringToArray(str: string): Uint8Array {
|
||||||
|
if (str == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
const arr = new Uint8Array(str.length);
|
const arr = new Uint8Array(str.length);
|
||||||
for (let i = 0; i < str.length; i++) {
|
for (let i = 0; i < str.length; i++) {
|
||||||
arr[i] = str.charCodeAt(i);
|
arr[i] = str.charCodeAt(i);
|
||||||
|
|||||||
Reference in New Issue
Block a user