mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 16:23:44 +00:00
Handle null in utils
This commit is contained in:
@@ -70,4 +70,10 @@ describe("Utils Service", () => {
|
||||
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 {
|
||||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
const arr = new Uint8Array(str.length);
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
arr[i] = str.charCodeAt(i);
|
||||
|
||||
Reference in New Issue
Block a user