mirror of
https://github.com/bitwarden/browser
synced 2026-03-02 11:31:44 +00:00
* [PM-3683] Remove ipcRenderer from electron-platform-utils * FIx review comments * Formatting * Use isNullOrWhitespace
22 lines
798 B
TypeScript
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);
|
|
});
|
|
});
|