summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAcid Chicken (硫酸鶏) <root@acid-chicken.com>2019-02-04 00:09:24 +0900
committerAcid Chicken (硫酸鶏) <root@acid-chicken.com>2019-02-04 00:09:24 +0900
commit8b71006fbec6b4a0f57828aea69420b610e9db4e (patch)
treeaca03b8c838a3c9ac97a9f416ee1ef28d89a3e50 /src
parentAdd missing semicolons (diff)
downloadmisskey-8b71006fbec6b4a0f57828aea69420b610e9db4e.tar.gz
misskey-8b71006fbec6b4a0f57828aea69420b610e9db4e.tar.bz2
misskey-8b71006fbec6b4a0f57828aea69420b610e9db4e.zip
Bye 'is-url'
Diffstat (limited to 'src')
-rw-r--r--src/@types/is-url.d.ts7
-rw-r--r--src/config/load.ts14
2 files changed, 9 insertions, 12 deletions
diff --git a/src/@types/is-url.d.ts b/src/@types/is-url.d.ts
deleted file mode 100644
index c1ccadd498..0000000000
--- a/src/@types/is-url.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-declare module 'is-url' {
- function isUrl(string: string): boolean;
-
- namespace isUrl {} // Hack
-
- export = isUrl;
-}
diff --git a/src/config/load.ts b/src/config/load.ts
index 57cfb8075c..fc3e699199 100644
--- a/src/config/load.ts
+++ b/src/config/load.ts
@@ -6,7 +6,6 @@ import * as fs from 'fs';
import { URL } from 'url';
import * as yaml from 'js-yaml';
import { Source, Mixin } from './types';
-import * as isUrl from 'is-url';
import * as pkg from '../../package.json';
/**
@@ -26,10 +25,7 @@ export default function load() {
const mixin = {} as Mixin;
- // Validate URLs
- if (!isUrl(config.url)) throw `url="${config.url}" is not a valid URL`;
-
- const url = new URL(config.url);
+ const url = validateUrl(config.url);
config.url = normalizeUrl(config.url);
mixin.host = url.host;
@@ -51,6 +47,14 @@ export default function load() {
return Object.assign(config, mixin);
}
+function validateUrl(url: string) {
+ try {
+ return new URL(url);
+ } catch (e) {
+ throw `url="${url}" is not a valid URL`;
+ }
+}
+
function normalizeUrl(url: string) {
return url.endsWith('/') ? url.substr(0, url.length - 1) : url;
}