From c0e75b8606267d50617807e251953ecc87b0a4e6 Mon Sep 17 00:00:00 2001 From: Sheogorath Date: Tue, 16 Apr 2019 19:27:02 +0200 Subject: [PATCH] Replace js-url with wurl js-url is outdated and wurl is it's successor. This will fix some vulnerabilities in the dependencies and also optimize the build process by removing the external library toward internal tooling. Signed-off-by: Sheogorath --- package.json | 2 +- public/js/history.js | 5 +++-- public/js/index.js | 5 +++-- public/views/index/foot.ejs | 1 - webpack.common.js | 3 --- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index c0d3cf9..4d52d47 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "jquery-ui": "^1.12.1", "js-cookie": "^2.1.3", "js-sequence-diagrams": "git+https://github.com/codimd/js-sequence-diagrams.git", - "js-url": "^2.3.0", + "wurl": "^2.5.3", "js-yaml": "^3.13.1", "jsdom-nogyp": "^0.8.3", "keymaster": "^1.6.2", diff --git a/public/js/history.js b/public/js/history.js index 6007bef..27b8cd2 100644 --- a/public/js/history.js +++ b/public/js/history.js @@ -4,6 +4,7 @@ import store from 'store' import S from 'string' import LZString from 'lz-string' +import url from 'wurl' import { checkNoteIdValid, @@ -23,9 +24,9 @@ window.migrateHistoryFromTempCallback = null migrateHistoryFromTemp() function migrateHistoryFromTemp () { - if (window.url('#tempid')) { + if (url('#tempid')) { $.get(`${serverurl}/temp`, { - tempid: window.url('#tempid') + tempid: url('#tempid') }) .done(data => { if (data && data.temp) { diff --git a/public/js/index.js b/public/js/index.js index c59c94d..d5345a8 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -17,6 +17,7 @@ import { saveAs } from 'file-saver' import randomColor from 'randomcolor' import store from 'store' import hljs from 'highlight.js' +import url from 'wurl' import _ from 'lodash' @@ -1373,12 +1374,12 @@ $('#gistImportModalConfirm').click(function () { if (!isValidURL(gisturl)) { showMessageModal(' Import from Gist', 'Not a valid URL :(', '', '', false) } else { - var hostname = window.url('hostname', gisturl) + var hostname = url('hostname', gisturl) if (hostname !== 'gist.github.com') { showMessageModal(' Import from Gist', 'Not a valid Gist URL :(', '', '', false) } else { ui.spinner.show() - $.get('https://api.github.com/gists/' + window.url('-1', gisturl)) + $.get('https://api.github.com/gists/' + url('-1', gisturl)) .done(function (data) { if (data.files) { var contents = '' diff --git a/public/views/index/foot.ejs b/public/views/index/foot.ejs index 54e39e1..b4b2998 100644 --- a/public/views/index/foot.ejs +++ b/public/views/index/foot.ejs @@ -5,7 +5,6 @@ - <%- include ../build/cover-scripts %> <% } else { %> diff --git a/webpack.common.js b/webpack.common.js index 1e9c070..5c79973 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -195,13 +195,11 @@ module.exports = { 'bootstrap-validator', 'expose-loader?select2!select2', 'expose-loader?moment!moment', - 'script-loader!js-url', path.join(__dirname, 'public/js/cover.js') ], index: [ 'babel-polyfill', 'script-loader!jquery-ui-resizable', - 'script-loader!js-url', 'script-loader!Idle.Js', 'expose-loader?LZString!lz-string', 'script-loader!codemirror', @@ -248,7 +246,6 @@ module.exports = { 'expose-loader?jsyaml!js-yaml', 'script-loader!mermaid', 'expose-loader?moment!moment', - 'script-loader!js-url', 'script-loader!handlebars', 'expose-loader?hljs!highlight.js', 'expose-loader?emojify!emojify.js',