fix: atto links (relative)
This commit is contained in:
parent
4d49fc3cdf
commit
6af56ed2b2
1 changed files with 10 additions and 5 deletions
|
@ -31,7 +31,9 @@ function fix_atto_links() {
|
||||||
|
|
||||||
if (TETRATTO_LINK_HANDLER_CTX === "embed") {
|
if (TETRATTO_LINK_HANDLER_CTX === "embed") {
|
||||||
// relative links for embeds
|
// relative links for embeds
|
||||||
const path = window.location.pathname.slice("/api/v1/net/".length);
|
const path = window.location.pathname
|
||||||
|
.replace("atto://", "")
|
||||||
|
.slice("/api/v1/net/".length);
|
||||||
|
|
||||||
function fix_element(
|
function fix_element(
|
||||||
selector = "a",
|
selector = "a",
|
||||||
|
@ -43,15 +45,19 @@ function fix_atto_links() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let x = new URL(y[property]).pathname;
|
const p = new URL(y[property]).pathname.replace("atto://", "");
|
||||||
|
let x = p.startsWith("/api/v1/net/")
|
||||||
|
? p.replace("/api/v1/net/", "")
|
||||||
|
: p.startsWith("/")
|
||||||
|
? `${path.split("/")[0]}${p}`
|
||||||
|
: p;
|
||||||
|
|
||||||
if (!x.includes(".html")) {
|
if (!x.includes(".html")) {
|
||||||
x = `${x}/index.html`;
|
x = `${x}/index.html`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (relative) {
|
if (relative) {
|
||||||
y[property] =
|
y[property] = `atto://${x}`;
|
||||||
`atto://${path.replace("atto://", "").split("/")[0]}${x}`;
|
|
||||||
} else {
|
} else {
|
||||||
y[property] =
|
y[property] =
|
||||||
`/api/v1/net/${path.replace("atto://", "").split("/")[0]}${x}?s=${globalThis.SECRET_SESSION}`;
|
`/api/v1/net/${path.replace("atto://", "").split("/")[0]}${x}?s=${globalThis.SECRET_SESSION}`;
|
||||||
|
@ -107,7 +113,6 @@ function fix_atto_links() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const href = structuredClone(anchor.href);
|
const href = structuredClone(anchor.href);
|
||||||
|
|
||||||
anchor.addEventListener("click", () => {
|
anchor.addEventListener("click", () => {
|
||||||
if (TETRATTO_LINK_HANDLER_CTX === "net") {
|
if (TETRATTO_LINK_HANDLER_CTX === "net") {
|
||||||
window.location.href = `/net/${href.replace("atto://", "")}`;
|
window.location.href = `/net/${href.replace("atto://", "")}`;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue