Skip to content

Commit 0ff548f

Browse files
committed
fix: default open URL to https:// when no protocol is given
1 parent c8aa858 commit 0ff548f

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/cli.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1062,8 +1062,13 @@ const SCROLL_FUNCTIONS: Record<string, string> = {
10621062
bottom: "window.scrollTo(0, document.body.scrollHeight)",
10631063
};
10641064

1065+
function normalizeUrl(raw: string): string {
1066+
if (/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(raw)) return raw;
1067+
return `https://${raw}`;
1068+
}
1069+
10651070
async function handleOpen(args: string[], full: boolean): Promise<string> {
1066-
const url = args[0];
1071+
const url = args[0] ? normalizeUrl(args[0]) : undefined;
10671072
if (!url) {
10681073
throw new CdpError("Missing URL", "VALIDATION_ERROR", [
10691074
"Run `opera-browser-cli open https://example.com` to navigate to a page",

0 commit comments

Comments
 (0)