Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
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
11 changes: 8 additions & 3 deletions src/extensions/default/WebPlatformDocs/InlineDocsViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,14 @@ define(function (require, exports, module) {
this.$wrapperDiv.find("a").each(function (index, elem) {
var $elem = $(elem);
var url = $elem.attr("href");
if (url && url.substr(0, 4) !== "http") {
// URLs in JSON data are relative
url = "http://docs.webplatform.org" + (url.charAt(0) !== "/" ? "/" : "") + url;
if (url) {
if (url.charAt(0) === "#") {
// Anchors in JSON data are relative to page URL
url = templateVars.url + url;
} else if (url.substr(0, 4) !== "http") {
// URLs in JSON data are relative
url = "http://docs.webplatform.org" + (url.charAt(0) !== "/" ? "/" : "") + url;
}
$elem.attr("href", url);
}
$elem.attr("title", url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
<a href="../relative/link" data-expected="http://docs.webplatform.org/../relative/link">relative</a>
<a href="file:///someplace/bad" data-expected="http://docs.webplatform.org/file:///someplace/bad">file url</a>
<a href="foo?querystring" data-expected="http://docs.webplatform.org/foo?querystring">querystring</a>
<a href="#hash" data-expected="http://docs.webplatform.org/#hash">hash</a>
<a href="#hash" data-expected="http://dev.brackets.io/wiki/css/properties/my-css-prop#hash">hash</a>
<a href="foo#hash" data-expected="http://docs.webplatform.org/foo#hash">hash</a>
4 changes: 2 additions & 2 deletions src/extensions/default/WebPlatformDocs/unittests.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ define(function (require, exports, module) {
href,
$links = viewer.$htmlContent.find("a:not(.close)");

// 7 links in description.html, 1 "more info" link in template
expect($links.length).toBe(8);
// 8 links in description.html, 1 "more info" link in template
expect($links.length).toBe(9);

$links.each(function (i, anchor) {
$a = $(anchor);
Expand Down