@scriptdb/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 +5 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -95,14 +95,16 @@ class ScriptDBClient {
|
|
|
95
95
|
this.retries = Number.isFinite(this.options.retries) ? this.options.retries : 3;
|
|
96
96
|
this.retryDelay = Number.isFinite(this.options.retryDelay) ? this.options.retryDelay : 1000;
|
|
97
97
|
this.frame = this.options.frame === "length-prefix" || this.options.preferLengthPrefix ? "length-prefix" : "ndjson";
|
|
98
|
-
const normalized = uri.replace(/^https?:\/\//i, "scriptdb://");
|
|
99
98
|
let parsed;
|
|
100
99
|
try {
|
|
101
|
-
parsed = new URL(
|
|
100
|
+
parsed = new URL(uri);
|
|
102
101
|
} catch (e) {
|
|
103
102
|
throw new Error("Invalid uri");
|
|
104
103
|
}
|
|
105
|
-
|
|
104
|
+
if (parsed.protocol !== "scriptdb:") {
|
|
105
|
+
throw new Error("URI must use scriptdb:// protocol");
|
|
106
|
+
}
|
|
107
|
+
this.uri = uri;
|
|
106
108
|
this.protocolName = parsed.protocol ? parsed.protocol.replace(":", "") : "scriptdb";
|
|
107
109
|
this.username = (typeof this.options.username === "string" ? this.options.username : parsed.username) || null;
|
|
108
110
|
this.password = (typeof this.options.password === "string" ? this.options.password : parsed.password) || null;
|