diff --git a/CHANGES.md b/CHANGES.md index 7dab65fb..3f04e4d9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -22,7 +22,8 @@ - Fix: Redirect paths for imagelib redirect checks - Optimization: Remove unused `jquery-ui-1.8.custom.min.js` file - Localization: Add 'SVG-Edit Home Page' to locale files -- Refactoring: Ensure file-global tags are at beginning of file +- Refactoring: Switch from `$.param.querystring` to `URL` +- Refactoring: Ensure file-global jsdoc tags are at beginning of file - Linting (ESLint): Simplify regexes - Linting (ESLint): Replace `innerHTML` with `textContent` from old demo - Linting (ESLint): Update as per latest ash-nazg diff --git a/editor/extensions/ext-server_moinsave.js b/editor/extensions/ext-server_moinsave.js index e2a8774b..f830f3d0 100644 --- a/editor/extensions/ext-server_moinsave.js +++ b/editor/extensions/ext-server_moinsave.js @@ -28,8 +28,8 @@ export default { svgEditor.setCustomHandlers({ async save (win, data) { const svg = '\n' + data; - const qstr = $.param.querystring(); - const [, name] = qstr.substr(9).split('/+get/'); + const {pathname} = new URL(location); + const name = pathname.replace(/\/+get\//, ''); const svgData = encode64(svg); if (!$('#export_canvas').length) { $('', {id: 'export_canvas'}).hide().appendTo('body'); diff --git a/editor/svg-editor.js b/editor/svg-editor.js index ee111dfb..8759854d 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -726,7 +726,6 @@ editor.init = function () { } (() => { // Load config/data from URL if given - let src, qstr; urldata = $.deparam.querystring(true); if (!$.isEmptyObject(urldata)) { if (urldata.dimensions) { @@ -759,19 +758,19 @@ editor.init = function () { setupCurConfig(); if (!curConfig.preventURLContentLoading) { - src = urldata.source; - qstr = $.param.querystring(); - if (!src) { // urldata.source may have been null if it ended with '=' - if (qstr.includes('source=data:')) { - src = qstr.match(/source=(data:[^&]*)/)[1]; - // ({src} = qstr.match(/source=(?data:[^&]*)/).groups); + let {source} = urldata; + if (!source) { // urldata.source may have been null if it ended with '=' + const {searchParams} = new URL(location); + const src = searchParams.get('source'); + if (src.startsWith('data:')) { + source = src; } } - if (src) { - if (src.startsWith('data:')) { - editor.loadFromDataURI(src); + if (source) { + if (source.startsWith('data:')) { + editor.loadFromDataURI(source); } else { - editor.loadFromString(src); + editor.loadFromString(source); } return; }