Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Commit

Permalink
Strip tracking url parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
drakkein committed Oct 15, 2019
1 parent 0daa03e commit 114068c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 11 deletions.
4 changes: 3 additions & 1 deletion app/ui/downloadPassword.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ module.exports = function(state, emit) {
const password = el.value;
if (password.length > 0) {
document.getElementById('password-btn').disabled = true;
state.fileInfo.url = window.location.href;
// Strip any url parameters between fileId and secretKey
const fileInfoUrl = window.location.href.replace(/\?.+#/, '#');
state.fileInfo.url = fileInfoUrl;
state.fileInfo.password = password;
emit('getMetadata');
}
Expand Down
25 changes: 25 additions & 0 deletions test/integration/download-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,29 @@ describe('Firefox Send', function() {
// check if upload and download file sizes are equal
assert.equal(uploadSize, downloadSize);
});

it(`should upload and download file with added tracking parameter`, function() {
const trackingUrl =
'?fbclid=IaMFak3Tr4ck1ng1d_SDlP0shBk8SM2EN3cCLFKpHVl-k-Pvv0sf9Zy0tnTu9srqVY';
const password = 'strongpassword';

browser.chooseFile(
homePage.uploadInput,
`${testFilesPath}/${testFiles[0]}`
);
browser.waitForExist(homePage.addPassword);
browser.click(homePage.addPassword);
browser.waitForExist(homePage.passwordInput);
browser.setValue(homePage.passwordInput, password);
browser.click(homePage.uploadButton);
browser.waitForExist(homePage.shareUrl);
const shareUrl = browser.getValue(homePage.shareUrl);
const downloadPage = new DownloadPage(
shareUrl.replace('#', `${trackingUrl}#`)
);
downloadPage.open();
downloadPage.downloadUsingPassword(password);
browser.waitForExist(downloadPage.downloadComplete);
assert.ok(fs.existsSync(path.join(downloadDir, testFiles[0])));
});
});
19 changes: 9 additions & 10 deletions test/integration/pages/desktop/download_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@ const Page = require('./page');
class DownloadPage extends Page {
constructor(path) {
super(path);
this.fileId = /download\/(\w+)\/#/.exec(path)[1];
this.fileId = /download\/(\w+)\/\??.*#/.exec(path)[1];
this.downloadButton = '#download-btn';
this.downloadComplete = '#download-complete';
this.passwordInput = '#password-input';
this.passwordButton = '#password-btn';
}

/**
* @function waitForPageToLoad
* @returns {Object} An object representing the page.
* @throws ElementNotFound
*/
waitForPageToLoad() {
super.waitForPageToLoad();
browser.waitForExist(this.downloadButton);
return this;
downloadUsingPassword(password) {
browser.waitForExist(this.passwordInput);
browser.setValue(this.passwordInput, password);
browser.click(this.passwordButton);
return browser.click(this.downloadButton);
}

download() {
browser.waitForExist(this.downloadButton);
return browser.click(this.downloadButton);
}
}
Expand Down
3 changes: 3 additions & 0 deletions test/integration/pages/desktop/home_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ class HomePage extends Page {
this.progress = 'progress';
this.shareUrl = '#share-url';
this.downloadCountSelect = '#expire-after-dl-count-select';
this.addPassword = '#add-password';
this.passwordInput = '#password-input';
this.passwordButton = '#password-btn';
}

waitForPageToLoad() {
Expand Down

0 comments on commit 114068c

Please sign in to comment.