Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put shortlinks into the metadata #470

Merged
merged 1 commit into from
Dec 15, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/plugin/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ function getLinks() {

if (!(rel === "alternate" ||
rel === "canonical" ||
rel === "shortlink" ||
rel === "bookmark")) {
return;
}
Expand Down
17 changes: 10 additions & 7 deletions test/spec/plugin/document_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ var FIXTURE_METADATA = {
'<link rel="bookmark" href="http://example.com/bookmark"></link>',
'<link rel="alternate" href="es/foo.html" hreflang="es" type="text/html"></link>',
'<link rel="alternate" href="feed" type="application/rss+xml"></link>',
'<link rel="canonical" href="http://example.com/bookmark/canonical.html"></link>'
'<link rel="canonical" href="http://example.com/bookmark/canonical.html"></link>',
'<link rel="shortlink" href="http://example.com/bookmark/short"></link>'
],
highwire: [
'<meta name="citation_doi" content="10.1175/JCLI-D-11-00015.1">',
Expand Down Expand Up @@ -66,7 +67,7 @@ describe('Document plugin', function () {

it('should have links with absolute hrefs and types', function () {
assert.ok(metadata.link);
assert.equal(metadata.link.length, 8);
assert.equal(metadata.link.length, 9);
assert.equal(metadata.link[0].href, window.location.href);
assert.equal(metadata.link[1].rel, "alternate");
assert.match(metadata.link[1].href, /^.+foo\.pdf$/);
Expand All @@ -78,14 +79,16 @@ describe('Document plugin', function () {
assert.equal(metadata.link[3].href, "http://example.com/bookmark");
assert.equal(metadata.link[4].rel, "canonical");
assert.equal(metadata.link[4].href, "http://example.com/bookmark/canonical.html");
assert.equal(metadata.link[5].href, "doi:10.1175/JCLI-D-11-00015.1");
assert.match(metadata.link[6].href, /.+foo\.pdf$/);
assert.equal(metadata.link[6].type, "application/pdf");
assert.equal(metadata.link[7].href, "doi:10.1175/JCLI-D-11-00015.1");
assert.equal(metadata.link[5].rel, "shortlink");
assert.equal(metadata.link[5].href, "http://example.com/bookmark/short");
assert.equal(metadata.link[6].href, "doi:10.1175/JCLI-D-11-00015.1");
assert.match(metadata.link[7].href, /.+foo\.pdf$/);
assert.equal(metadata.link[7].type, "application/pdf");
assert.equal(metadata.link[8].href, "doi:10.1175/JCLI-D-11-00015.1");
});

it('should ignore atom and RSS feeds and alternate languages', function () {
assert.equal(metadata.link.length, 8);
assert.equal(metadata.link.length, 9);
});

it('should have highwire metadata', function () {
Expand Down