diff --git a/src/js/url_exist.js b/src/js/url_exist.js index 01e6814..85c8716 100644 --- a/src/js/url_exist.js +++ b/src/js/url_exist.js @@ -62,17 +62,18 @@ function checkIfInternalLinksExists(ref, title, url, history) { //verify by checking if the url starts with the blog url let cleanURL = url.href.replace(url.host, "").replace(/http(s)?:(\/){1,3}/gi, "").replace(/^\//, ""); cleanURL = cleanURL.trim().length === 0 ? "./" : decodeURI(cleanURL).toLowerCase(); - const part = window.location.pathname; + const blogURL = document.querySelector('meta[name="site_url"]').content; + const part = blogURL.split("/").filter((part) => part.length > 0).pop() + "/"; + /** get last part of the url, like wiki in 127.0.0.1:8000/wiki/ */ cleanURL = cleanURL.replace(part.replace(/^\//, ""), ""); if (!history.includes(cleanURL.replace(/\/$/, "")) && cleanURL !== "./") { - fetch(`${part}/search/all_files.json`) + fetch(`${blogURL}/search/all_files.json`) .then((response) => response.json()) .then((json) => { json.forEach((doc) => { const docURL = decodeURI(doc.url).toLowerCase(); - console.log(docURL, "----------", cleanURL) if (docURL === cleanURL) { history.push(cleanURL.replace(/\/$/, "")); }