Commit f2c7c707 authored by Robert Knight's avatar Robert Knight Committed by GitHub

Merge pull request #3441 from hypothesis/sheetaluk/pdf-metadata

Remove path for local pdf files.
parents 7e95361d 99c69180
......@@ -49,10 +49,16 @@ PDFMetadata.prototype.getMetadata = function () {
}
var link = [
{href: fingerprintToURN(app.documentFingerprint)},
{href: app.url}
{href: fingerprintToURN(app.documentFingerprint)}
];
// Local file:// URLs should not be saved in document metadata.
// Entries in document.link should be URIs. In the case of
// local files, omit the URL.
if (app.url.indexOf('file://') !== 0) {
link.push({href: app.url});
}
return {
title: title,
link: link,
......
......@@ -83,6 +83,24 @@ describe('pdf-metadata', function () {
assert.deepEqual(actualMetadata, expectedMetadata);
});
});
it('does not save file:// URLs in document metadata', function () {
var pdfMetadata;
var fakePDFViewerApplication = {
documentFingerprint: 'fakeFingerprint',
url: 'file://fakeUrl',
};
var expectedMetadata = {
link: [{href: 'urn:x-pdf:' + fakePDFViewerApplication.documentFingerprint}],
};
pdfMetadata = new PDFMetadata(fakePDFViewerApplication);
return pdfMetadata.getMetadata().then(function (actualMetadata) {
assert.equal(actualMetadata.link.length, 1);
assert.equal(actualMetadata.link[0].href, expectedMetadata.link[0].href);
});
});
});
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment