aboutsummaryrefslogtreecommitdiff
path: root/src/fields/URLField.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-04-17 12:27:21 -0400
committerbobzel <zzzman@gmail.com>2024-04-17 12:27:21 -0400
commit2a313f28fcb8675223708b0657de7517a3281095 (patch)
treeed6db226cc7d323aee378eddee43dc5f3bdb1ef9 /src/fields/URLField.ts
parent62937027183dc8acf14e489fbb4590aff6fce2cd (diff)
restoring eslint - updates not complete yet
Diffstat (limited to 'src/fields/URLField.ts')
-rw-r--r--src/fields/URLField.ts32
1 files changed, 15 insertions, 17 deletions
diff --git a/src/fields/URLField.ts b/src/fields/URLField.ts
index 87334ad16..c6c51957d 100644
--- a/src/fields/URLField.ts
+++ b/src/fields/URLField.ts
@@ -1,18 +1,14 @@
+import { custom, serializable } from 'serializr';
+import { ClientUtils } from '../ClientUtils';
+import { scriptingGlobal } from '../client/util/ScriptingGlobals';
import { Deserializable } from '../client/util/SerializationHelper';
-import { serializable, custom } from 'serializr';
+import { Copy, ToJavascriptString, ToScriptString, ToString } from './FieldSymbols';
import { ObjectField } from './ObjectField';
-import { ToScriptString, ToString, Copy, ToJavascriptString } from './FieldSymbols';
-import { scriptingGlobal } from '../client/util/ScriptingGlobals';
-import { Utils } from '../Utils';
function url() {
return custom(
- function (value: URL) {
- return value?.origin === window.location.origin ? value.pathname : value?.href;
- },
- function (jsonValue: string) {
- return new URL(jsonValue, window.location.origin);
- }
+ (value: URL) => (value?.origin === window.location.origin ? value.pathname : value?.href),
+ (jsonValue: string) => new URL(jsonValue, window.location.origin)
);
}
@@ -24,26 +20,28 @@ export abstract class URLField extends ObjectField {
constructor(url: URL);
constructor(url: URL | string) {
super();
- if (typeof url === 'string') {
- url = url.startsWith('http') ? new URL(url) : new URL(url, window.location.origin);
- }
- this.url = url;
+ this.url =
+ typeof url !== 'string'
+ ? url // it's an URL
+ : url.startsWith('http')
+ ? new URL(url)
+ : new URL(url, window.location.origin);
}
[ToScriptString]() {
- if (Utils.prepend(this.url?.pathname) === this.url?.href) {
+ if (ClientUtils.prepend(this.url?.pathname) === this.url?.href) {
return `new ${this.constructor.name}("${this.url.pathname}")`;
}
return `new ${this.constructor.name}("${this.url?.href}")`;
}
[ToJavascriptString]() {
- if (Utils.prepend(this.url?.pathname) === this.url?.href) {
+ if (ClientUtils.prepend(this.url?.pathname) === this.url?.href) {
return `new ${this.constructor.name}("${this.url.pathname}")`;
}
return `new ${this.constructor.name}("${this.url?.href}")`;
}
[ToString]() {
- if (Utils.prepend(this.url?.pathname) === this.url?.href) {
+ if (ClientUtils.prepend(this.url?.pathname) === this.url?.href) {
return this.url.pathname;
}
return this.url?.href;