From 13bd859f315ff56983d36a661f761d9c148c3187 Mon Sep 17 00:00:00 2001 From: John McLear Date: Fri, 5 Jun 2020 19:58:25 +0100 Subject: [PATCH] Import/export: Fix3032 - importing document botches pad options (#3769) Fixes #3032 --- src/static/js/pad.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/static/js/pad.js b/src/static/js/pad.js index cdc2b4a60..7f1b6d406 100644 --- a/src/static/js/pad.js +++ b/src/static/js/pad.js @@ -437,16 +437,27 @@ var pad = { }, switchToPad: function(padId) { + var newHref = new RegExp(/.*\/p\/[^\/]+/).exec(document.location.pathname) || clientVars.padId; + newHref = newHref[0]; + + var options = clientVars.padOptions; + if (typeof options != "undefined" && options != null) + { + var option_str = []; + $.each(options, function(k,v) { + var str = k + "=" + v; + option_str.push(str); + }); + var option_str = option_str.join("&"); + + newHref = newHref + '?' + option_str; + } + // destroy old pad from DOM // See https://github.com/ether/etherpad-lite/pull/3915 // TODO: Check if Destroying is enough and doesn't leave negative stuff // See ace.js "editor.destroy" for a reference of how it was done before $('#editorcontainer').find("iframe")[0].remove(); - var options = document.location.href.split('?')[1]; - var newHref = padId; - if (typeof options != "undefined" && options != null){ - newHref = newHref + '?' + options; - } if(window.history && window.history.pushState) {