@scriptdb/browser-client 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +9 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -77,14 +77,19 @@ class BrowserClient {
|
|
|
77
77
|
this.requestTimeout = Number.isFinite(this.options.requestTimeout) ? this.options.requestTimeout : 0;
|
|
78
78
|
this.retries = Number.isFinite(this.options.retries) ? this.options.retries : 3;
|
|
79
79
|
this.retryDelay = Number.isFinite(this.options.retryDelay) ? this.options.retryDelay : 1000;
|
|
80
|
-
const normalized = uri.replace(/^https?:\/\//i, "scriptdb://").replace(/^wss?:\/\//i, "scriptdb://");
|
|
81
80
|
let parsed;
|
|
82
81
|
try {
|
|
83
|
-
parsed = new URL(
|
|
82
|
+
parsed = new URL(uri);
|
|
84
83
|
} catch (e) {
|
|
85
84
|
throw new Error("Invalid uri");
|
|
86
85
|
}
|
|
87
|
-
|
|
86
|
+
if (parsed.protocol !== "scriptdb:") {
|
|
87
|
+
throw new Error("URI must use scriptdb:// protocol");
|
|
88
|
+
}
|
|
89
|
+
if (parsed.protocol !== "scriptdb:") {
|
|
90
|
+
throw new Error("URI must use scriptdb:// protocol");
|
|
91
|
+
}
|
|
92
|
+
this.uri = uri;
|
|
88
93
|
this.protocolName = parsed.protocol ? parsed.protocol.replace(":", "") : "scriptdb";
|
|
89
94
|
this.username = (typeof this.options.username === "string" ? this.options.username : decodeURIComponent(parsed.username)) || null;
|
|
90
95
|
this.password = (typeof this.options.password === "string" ? this.options.password : decodeURIComponent(parsed.password)) || null;
|
|
@@ -96,7 +101,7 @@ class BrowserClient {
|
|
|
96
101
|
parsed.password = "";
|
|
97
102
|
this.uri = parsed.toString();
|
|
98
103
|
} catch (e) {
|
|
99
|
-
this.uri =
|
|
104
|
+
this.uri = uri;
|
|
100
105
|
}
|
|
101
106
|
this.host = parsed.hostname || "localhost";
|
|
102
107
|
this.port = parsed.port ? parseInt(parsed.port, 10) : 1234;
|