Organized the differences between server and docker versions.
We are launching a docker version (server version) today so we want to just organize the repo so its easier to navigate.
This commit is contained in:
51
desktop/src/scripts/utils/url-utils.js
Normal file
51
desktop/src/scripts/utils/url-utils.js
Normal file
@@ -0,0 +1,51 @@
|
||||
const URLUtils = {
|
||||
|
||||
parseEntityPath(basePath = 'anime') {
|
||||
const path = window.location.pathname;
|
||||
const parts = path.split("/").filter(Boolean);
|
||||
|
||||
if (parts[0] !== basePath) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (parts.length === 3) {
|
||||
|
||||
return {
|
||||
extensionName: parts[1],
|
||||
entityId: parts[2],
|
||||
slug: parts[2]
|
||||
};
|
||||
} else if (parts.length === 2) {
|
||||
|
||||
return {
|
||||
extensionName: null,
|
||||
entityId: parts[1],
|
||||
slug: null
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
buildWatchUrl(animeId, episode, extensionName = null) {
|
||||
const base = `/watch/${animeId}/${episode}`;
|
||||
return extensionName ? `${base}?${extensionName}` : base;
|
||||
},
|
||||
|
||||
buildReadUrl(bookId, chapterId, provider, extensionName = null) {
|
||||
const c = encodeURIComponent(chapterId);
|
||||
const p = encodeURIComponent(provider);
|
||||
const extension = extensionName ? `?source=${extensionName}` : "?source=anilist";
|
||||
return `/read/${p}/${c}/${bookId}${extension}`;
|
||||
},
|
||||
|
||||
getQueryParams() {
|
||||
return new URLSearchParams(window.location.search);
|
||||
},
|
||||
|
||||
getQueryParam(key) {
|
||||
return this.getQueryParams().get(key);
|
||||
}
|
||||
};
|
||||
|
||||
window.URLUtils = URLUtils;
|
||||
Reference in New Issue
Block a user