Skip to content
This repository has been archived by the owner on Dec 24, 2024. It is now read-only.

Commit

Permalink
fix again
Browse files Browse the repository at this point in the history
  • Loading branch information
Mara-Li committed Jul 14, 2023
1 parent 776b7c5 commit af3c4ea
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/js/url_exist.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(/\/$/, ""));
}
Expand Down

0 comments on commit af3c4ea

Please sign in to comment.