Skip to content

Commit cf76e2d

Browse files
committed
Load images relative to the local URL of the markdown page if applicable
1 parent 07ff7d5 commit cf76e2d

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

markdown/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@
255255
const selfHosted = repo == 'www.eclipse.org-eclipse';
256256
const repoName = parts == null ? '' : repoNames[`${org}/${repo}`];
257257

258+
var applicableLocalURL = null;
259+
258260
const localSiteNavigator = isLocalHost ? `<a href="${getMarkdownURL('eclipse-platform/www.eclipse.org-eclipse/master/')}">Eclipse Website Navigator</a>` : '';
259261
defaultAside = toElements(`${markdownAside}${localSiteNavigator}`);
260262

@@ -444,6 +446,8 @@ <h2>Table of Contents</h2>
444446
const siteURL = toSiteURL(logicalSrc);
445447
if (siteURL != null) {
446448
img.src = siteURL;
449+
} else if (applicableLocalURL != null) {
450+
img.src = new URL(src, applicableLocalURL);
447451
} else {
448452
img.src = new URL(`https://raw.githubusercontent.com/${org}/${repo}/${branch}/${path}/../${src}`);
449453
}
@@ -622,6 +626,7 @@ <h2>Table of Contents</h2>
622626
localURL.pathname = `${org}/${repo}/${branch}/${path}`;
623627
fetch(localURL, {method: 'HEAD', cache: "no-store"}).then(response => {
624628
if (response.status == 200 && response.headers.get('Server') == 'org.eclipse.oomph.internal.util.HTTPServer') {
629+
applicableLocalURL = localURL;
625630
defaultHandler(localURL);
626631
} else {
627632
defaultHandler(defaultURL);

0 commit comments

Comments
 (0)