Skip to content
This repository has been archived by the owner on Jan 23, 2022. It is now read-only.

Commit

Permalink
fix(docs): run from file:// url again
Browse files Browse the repository at this point in the history
  • Loading branch information
m7r committed Mar 11, 2015
1 parent a72023e commit c9f528a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/templates/index.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@
// before the base attribute is added, causing 404 and terribly slow loading of the docs app.
(function() {
var indexFile = (location.pathname.match(/\/(index[^\.]*\.html)/) || ['', ''])[1],
rUrl = /(#!\/|<%= sections %>|index[^\.]*\.html).*$/,
origin = location.origin || (window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: '')),
baseUrl = origin + location.href.substr(origin.length).replace(rUrl, indexFile),
origin, baseUrl, rUrl = /(#!\/|<%= sections %>|index[^\.]*\.html).*$/,
headEl = document.getElementsByTagName('head')[0],
sync = true;

if (location.href.slice(0, 7) == 'file://') {
baseUrl = location.href.replace(rUrl, indexFile);
} else {
origin = location.origin || (window.location.protocol + "//" + window.location.hostname +
(window.location.port ? ':' + window.location.port: ''));
baseUrl = origin + location.href.substr(origin.length).replace(rUrl, indexFile);
}

addTag('base', {href: baseUrl});
addTag('link', {rel: 'stylesheet', href: 'css/bootstrap.min.css', type: 'text/css'});
addTag('link', {rel: 'stylesheet', href: 'css/font-awesome.css', type: 'text/css'});
Expand Down

1 comment on commit c9f528a

@chfw
Copy link

@chfw chfw commented on c9f528a Mar 13, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'file://' worked in my end. Looking forward to your release

Please sign in to comment.