1
0
mirror of https://github.com/bitwarden/browser synced 2026-03-02 11:31:44 +00:00
Files
browser/libs/common/src/platform/misc/safe-urls.spec.ts
Daniel García c592bcba80 [PM-3683] Remove ipcRenderer from electron-platform-utils (#6679)
* [PM-3683] Remove ipcRenderer from electron-platform-utils

* FIx review comments

* Formatting

* Use isNullOrWhitespace
2023-11-01 18:34:36 +01:00

22 lines
798 B
TypeScript

import { SafeUrls } from "./safe-urls";
describe("SafeUrls service", () => {
it("should allow valid URLs", () => {
expect(SafeUrls.canLaunch("https://bitwarden.com")).toBe(true);
expect(SafeUrls.canLaunch("http://bitwarden.com")).toBe(true);
expect(SafeUrls.canLaunch("ssh://my-server")).toBe(true);
});
it("should fail invalid URLs", () => {
expect(SafeUrls.canLaunch("bitwarden.com")).toBe(false);
expect(SafeUrls.canLaunch("")).toBe(false);
expect(SafeUrls.canLaunch(null)).toBe(false);
});
it("should fail URLs with disallowed protocols", () => {
expect(SafeUrls.canLaunch("file:///etc/passwd")).toBe(false);
expect(SafeUrls.canLaunch("\\\\network.share\\abc")).toBe(false);
expect(SafeUrls.canLaunch("smb://smb.server")).toBe(false);
});
});