Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: url detection (#4046)

Myles Scolnick44e1182e2593
diff --git a/frontend/src/utils/__tests__/urls.test.ts b/frontend/src/utils/__tests__/urls.test.ts
new file mode 100644
index 0000000000..351a0c100f
--- /dev/null
+++ b/frontend/src/utils/__tests__/urls.test.ts
@@ -0,0 +1,10 @@
+/* Copyright 2024 Marimo. All rights reserved. */
+import { describe, it, expect } from "vitest";
+import { isUrl } from "../urls";
+
+describe("isUrl", () => {
+ it("should return true for a valid URL", () => {
+ expect(isUrl("https://example.com")).toBe(true);
+ expect(isUrl("curl -X GET http://example.com")).toBe(false);
+ });
+});
diff --git a/frontend/src/utils/urls.ts b/frontend/src/utils/urls.ts
index cb571e3e7e..2fbb5694d0 100644
--- a/frontend/src/utils/urls.ts
+++ b/frontend/src/utils/urls.ts
@@ -27,7 +27,7 @@ export function newNotebookURL() {
return asURL(`?file=${initializationId}`).toString();
}
-const urlRegex = /(https?:\/\/\S+)/g;
+const urlRegex = /^(https?:\/\/\S+)$/;
export function isUrl(value: unknown): boolean {
return typeof value === "string" && urlRegex.test(value);
}