aboutsummaryrefslogtreecommitdiff
path: root/src/new_fields/URLField.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/new_fields/URLField.ts')
-rw-r--r--src/new_fields/URLField.ts9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/new_fields/URLField.ts b/src/new_fields/URLField.ts
index a6f8f1cc5..4a2841fb6 100644
--- a/src/new_fields/URLField.ts
+++ b/src/new_fields/URLField.ts
@@ -18,13 +18,18 @@ export abstract class URLField extends ObjectField {
@serializable(url())
readonly url: URL;
- constructor(url: URL) {
+ constructor(url: string);
+ constructor(url: URL);
+ constructor(url: URL | string) {
super();
+ if (typeof url === "string") {
+ url = new URL(url);
+ }
this.url = url;
}
[ToScriptString]() {
- return `new ${this.constructor.name}(new URL(${this.url.href}))`;
+ return `new ${this.constructor.name}("${this.url.href}")`;
}
[Copy](): this {