diff --git a/client/dom/current-file.js b/client/dom/current-file.js index d145ab71..d1a08795 100644 --- a/client/dom/current-file.js +++ b/client/dom/current-file.js @@ -34,7 +34,7 @@ module.exports.setCurrentName = (name, current) => { link.href = dir + encoded; link.innerHTML = encoded; - current.setAttribute('data-name', 'js-file-' + btoa(name)); + current.setAttribute('data-name', 'js-file-' + btoa(encodeURI(name))); CloudCmd.emit('current-file', current); return link; diff --git a/client/dom/current-file.spec.js b/client/dom/current-file.spec.js index e9567950..c18748c9 100644 --- a/client/dom/current-file.spec.js +++ b/client/dom/current-file.spec.js @@ -30,6 +30,30 @@ test('current-file: setCurrentName: setAttribute', (t) => { t.end(); }); +test('current-file: setCurrentName: setAttribute: cyrillic', (t) => { + const { + DOM, + CloudCmd, + } = global; + + global.DOM = getDOM(); + global.CloudCmd = getCloudCmd(); + + const setAttribute = sinon.stub(); + const current = { + setAttribute + }; + + currentFile.setCurrentName('ай', current); + + t.ok(setAttribute.calledWith('data-name', 'js-file-JUQwJUIwJUQwJUI5'), 'should call setAttribute'); + + global.DOM = DOM; + global.CloudCmd = CloudCmd; + + t.end(); +}); + test('current-file: emit', (t) => { const { DOM, diff --git a/client/dom/index.js b/client/dom/index.js index 820c7107..963e5718 100644 --- a/client/dom/index.js +++ b/client/dom/index.js @@ -188,7 +188,7 @@ function CmdProto() { * get current file by name */ this.getCurrentByName = (name, panel = CurrentInfo.panel) => { - const dataName = 'js-file-' + btoa(name); + const dataName = 'js-file-' + btoa(encodeURI(name)); const element = DOM.getByDataName(dataName, panel); return element; diff --git a/common/cloudfunc.js b/common/cloudfunc.js index 3ae6a69d..bb806ef6 100644 --- a/common/cloudfunc.js +++ b/common/cloudfunc.js @@ -97,7 +97,7 @@ function getPathLink(url, prefix, template) { } const getDataName = (name) => { - const encoded = btoa(name); + const encoded = btoa(encodeURI(name)); return `data-name="js-file-${encoded}" `; }; diff --git a/test/common/cloudfunc.html b/test/common/cloudfunc.html index dac3354b..2251e69a 100644 --- a/test/common/cloudfunc.html +++ b/test/common/cloudfunc.html @@ -19,9 +19,9 @@ 21.02.2016 root rwx r-x r-x -