diff --git a/src/core/fetch/index.js b/src/core/fetch/index.js index 7a66e0a78..0fac23bee 100644 --- a/src/core/fetch/index.js +++ b/src/core/fetch/index.js @@ -73,7 +73,7 @@ export function fetchMixin(proto) { case 'object': key = Object.keys(notFoundPage) .sort((a, b) => b.length - a.length) - .find(k => path.match(new RegExp('^' + k))); + .filter(k => path.match(new RegExp('^' + k)))[0]; path404 = (key && notFoundPage[key]) || defaultPath; break; diff --git a/src/core/render/compiler/link.js b/src/core/render/compiler/link.js index 22ff59d07..fd8b81138 100644 --- a/src/core/render/compiler/link.js +++ b/src/core/render/compiler/link.js @@ -29,7 +29,7 @@ export const linkCompiler = ({ href = router.toURL(href, null, router.getCurrentPath()); } else { - if (!isAbsolutePath(href) && href.startsWith('./')) { + if (!isAbsolutePath(href) && href.slice(0, 2) === './') { href = document.URL.replace(/\/(?!.*\/).*/, '/').replace('#/./', '') + href; } diff --git a/src/core/render/embed.js b/src/core/render/embed.js index 5159754ab..7a5cf3b68 100644 --- a/src/core/render/embed.js +++ b/src/core/render/embed.js @@ -26,7 +26,7 @@ function walkFetchEmbed({ embedTokens, compile, fetch }, cb) { // Resolves relative links to absolute text = text.replace(/\[([^[\]]+)\]\(([^)]+)\)/g, x => { const linkBeginIndex = x.indexOf('('); - if (x.substring(linkBeginIndex).startsWith('(.')) { + if (x.slice(linkBeginIndex, linkBeginIndex + 2) === '(.') { return ( x.substring(0, linkBeginIndex) + `(${window.location.protocol}//${window.location.host}${path}/` + diff --git a/src/core/render/index.js b/src/core/render/index.js index 35666226d..9e7b50fbd 100644 --- a/src/core/render/index.js +++ b/src/core/render/index.js @@ -255,8 +255,10 @@ export function renderMixin(proto) { if (hideSidebar) { // FIXME : better styling solution - document.querySelector('aside.sidebar').remove(); - document.querySelector('button.sidebar-toggle').remove(); + [ + document.querySelector('aside.sidebar'), + document.querySelector('button.sidebar-toggle'), + ].forEach(node => node.parentNode.removeChild(node)); document.querySelector('section.content').style.right = 'unset'; document.querySelector('section.content').style.left = 'unset'; document.querySelector('section.content').style.position = 'relative'; diff --git a/src/plugins/search/search.js b/src/plugins/search/search.js index dd809d791..07740e6df 100644 --- a/src/plugins/search/search.js +++ b/src/plugins/search/search.js @@ -245,8 +245,9 @@ export function init(config, vm) { if (Array.isArray(config.pathNamespaces)) { namespaceSuffix = - config.pathNamespaces.find(prefix => path.startsWith(prefix)) || - namespaceSuffix; + config.pathNamespaces.filter( + prefix => path.slice(0, prefix.length) === prefix + )[0] || namespaceSuffix; } else if (config.pathNamespaces instanceof RegExp) { const matches = path.match(config.pathNamespaces);