summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--public/js/extra.js13
-rw-r--r--webpack.common.js2
2 files changed, 5 insertions, 10 deletions
diff --git a/public/js/extra.js b/public/js/extra.js
index a6b01a91..0a95b1b1 100644
--- a/public/js/extra.js
+++ b/public/js/extra.js
@@ -178,16 +178,11 @@ function slugifyWithUTF8 (text) {
}
export function isValidURL (str) {
- const pattern = new RegExp('^(https?:\\/\\/)?' + // protocol
- '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // domain name
- '((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address
- '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path
- '(\\?[;&a-z\\d%_.~+=-]*)?' + // query string
- '(\\#[-a-z\\d_]*)?$', 'i') // fragment locator
- if (!pattern.test(str)) {
+ try {
+ const url = new URL(str)
+ return ['http:', 'https:'].includes(url.protocol)
+ } catch (e) {
return false
- } else {
- return true
}
}
diff --git a/webpack.common.js b/webpack.common.js
index 9f58610c..1f522178 100644
--- a/webpack.common.js
+++ b/webpack.common.js
@@ -513,7 +513,7 @@ module.exports = {
modules: ['node_modules'],
extensions: ['.js'],
alias: {
- 'codemirror-lib-codemirror': path.join(__dirname, 'node_modules/codemirror/lib/codemirror.js'),
+ 'codemirror-lib-codemirror': path.join(__dirname, 'node_modules/codemirror/src/codemirror.js'),
'codemirror-addon-mode-overlay': path.join(__dirname, 'node_modules/codemirror/addon/mode/overlay.js'),
'codemirror-addon-mode-simple': path.join(__dirname, 'node_modules/codemirror/addon/mode/simple.js'),
'codemirror-addon-mode-multiplex': path.join(__dirname, 'node_modules/codemirror/addon/mode/multiplex.js'),