mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 14:13:34 +01:00
import/export: Timeslider export links numeric pad IDs (#4073)
Fixes #4071
This commit is contained in:
parent
6dbfe5e43c
commit
56f6973209
2 changed files with 79 additions and 1 deletions
|
@ -141,13 +141,24 @@ function handleClientVars(message)
|
||||||
//initialize export ui
|
//initialize export ui
|
||||||
require('./pad_impexp').padimpexp.init();
|
require('./pad_impexp').padimpexp.init();
|
||||||
|
|
||||||
|
// Create a base URI used for timeslider exports
|
||||||
|
var baseURI = document.location.pathname;
|
||||||
|
|
||||||
//change export urls when the slider moves
|
//change export urls when the slider moves
|
||||||
BroadcastSlider.onSlider(function(revno)
|
BroadcastSlider.onSlider(function(revno)
|
||||||
{
|
{
|
||||||
// export_links is a jQuery Array, so .each is allowed.
|
// export_links is a jQuery Array, so .each is allowed.
|
||||||
export_links.each(function()
|
export_links.each(function()
|
||||||
{
|
{
|
||||||
this.setAttribute('href', this.href.replace( /(.+?)\/[^\/]+\/(\d+\/)?export/ , '$1/' + padId + '/' + revno + '/export'));
|
// Modified from regular expression to fix:
|
||||||
|
// https://github.com/ether/etherpad-lite/issues/4071
|
||||||
|
// Where a padId that was numeric would create the wrong export link
|
||||||
|
if(this.href){
|
||||||
|
var type = this.href.split('export/')[1];
|
||||||
|
var href = baseURI.split('timeslider')[0];
|
||||||
|
href += revno + '/export/' + type;
|
||||||
|
this.setAttribute('href', href);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
67
tests/frontend/specs/timeslider_numeric_padID.js
Normal file
67
tests/frontend/specs/timeslider_numeric_padID.js
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
describe("timeslider", function(){
|
||||||
|
var padId = 735773577357+(Math.round(Math.random()*1000));
|
||||||
|
|
||||||
|
//create a new pad before each test run
|
||||||
|
beforeEach(function(cb){
|
||||||
|
helper.newPad(cb, padId);
|
||||||
|
this.timeout(60000);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Makes sure the export URIs are as expected when the padID is numeric", function(done) {
|
||||||
|
var inner$ = helper.padInner$;
|
||||||
|
var chrome$ = helper.padChrome$;
|
||||||
|
|
||||||
|
// make some changes to produce 100 revisions
|
||||||
|
var revs = 10;
|
||||||
|
this.timeout(60000);
|
||||||
|
for(var i=0; i < revs; i++) {
|
||||||
|
setTimeout(function() {
|
||||||
|
// enter 'a' in the first text element
|
||||||
|
inner$("div").first().sendkeys('a');
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(function() {
|
||||||
|
// go to timeslider
|
||||||
|
$('#iframe-container iframe').attr('src', $('#iframe-container iframe').attr('src')+'/timeslider');
|
||||||
|
|
||||||
|
setTimeout(function() {
|
||||||
|
var timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
||||||
|
var $sliderBar = timeslider$('#ui-slider-bar');
|
||||||
|
|
||||||
|
var latestContents = timeslider$('#padcontent').text();
|
||||||
|
|
||||||
|
// Expect the date and time to be shown
|
||||||
|
|
||||||
|
// Click somewhere on the timeslider
|
||||||
|
var e = new jQuery.Event('mousedown');
|
||||||
|
e.clientX = e.pageX = 150;
|
||||||
|
e.clientY = e.pageY = 45;
|
||||||
|
$sliderBar.trigger(e);
|
||||||
|
|
||||||
|
e = new jQuery.Event('mousedown');
|
||||||
|
e.clientX = e.pageX = 150;
|
||||||
|
e.clientY = e.pageY = 40;
|
||||||
|
$sliderBar.trigger(e);
|
||||||
|
|
||||||
|
e = new jQuery.Event('mousedown');
|
||||||
|
e.clientX = e.pageX = 150;
|
||||||
|
e.clientY = e.pageY = 50;
|
||||||
|
$sliderBar.trigger(e);
|
||||||
|
|
||||||
|
$sliderBar.trigger('mouseup')
|
||||||
|
|
||||||
|
setTimeout(function() {
|
||||||
|
// expect URI to be similar to
|
||||||
|
// http://192.168.1.48:9001/p/2/2/export/html
|
||||||
|
// http://192.168.1.48:9001/p/735773577399/0/export/html
|
||||||
|
var exportLink = timeslider$('#exporthtmla').attr('href');
|
||||||
|
var checkVal = padId + "/0/export/html";
|
||||||
|
var includesCorrectURI = exportLink.indexOf(checkVal);
|
||||||
|
expect(includesCorrectURI).to.not.be(-1);
|
||||||
|
done();
|
||||||
|
}, 400);
|
||||||
|
}, 2000);
|
||||||
|
}, 2000);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in a new issue