fix chapterUrl to avoid duplicate chapters

This commit is contained in:
Rajarshee Chatterjee
2021-04-30 11:02:43 +05:30
parent cfd31bea02
commit eb352ae7ac
3 changed files with 17 additions and 13 deletions
+5 -4
View File
@@ -82,16 +82,17 @@ router.get("/novel/:novelUrl", (req, res) => {
let novelChapters = [];
$(".chapter").each(function (result) {
chapterName = $(this).text();
let chapterName = $(this).text();
releaseDate = null;
let releaseDate = null;
chapterUrl = $(this).attr("href");
let chapterUrl = $(this).attr("href");
chapterUrl = chapterUrl.replace(`/${novelUrl}/`, "");
novelChapters.push({
chapterName,
releaseDate,
chapterUrl: chapterUrl.replace(`/${novelUrl}/`, ""),
chapterUrl,
});
});
+7 -5
View File
@@ -109,10 +109,12 @@ router.get("/novel/:novelUrl", (req, res) => {
releaseDate = null;
chapterUrl = $(this)
.find("a")
.attr("href")
.replace(baseUrl, "");
chapterUrl = $(this).find("a").attr("href");
chapterUrl = chapterUrl.replace(
`${baseUrl}/${novelUrl}/`,
""
);
if (volumeName.includes("Volume")) {
chapterName = volumeName + " " + chapterName;
@@ -121,7 +123,7 @@ router.get("/novel/:novelUrl", (req, res) => {
novelChapters.push({
chapterName,
releaseDate,
chapterUrl: chapterUrl.replace(`/${novelUrl}/`, ""),
chapterUrl,
});
});
});
+5 -4
View File
@@ -93,16 +93,17 @@ router.get("/novel/:novelUrl", (req, res) => {
$(".panel-body")
.find("li")
.each(function (result) {
chapterName = $(this).find("a").attr("title");
let chapterName = $(this).find("a").attr("title");
releaseDate = null;
let releaseDate = null;
chapterUrl = $(this).find("a").attr("href");
let chapterUrl = $(this).find("a").attr("href");
chapterUrl = chapterUrl.replace(`/${novelUrl}/`, "");
novelChapters.push({
chapterName,
releaseDate,
chapterUrl: chapterUrl.replace(`/${novelUrl}/`, ""),
chapterUrl,
});
});