support multiple urls in the ForUrl field
This commit is contained in:
parent
2f3c5b7769
commit
d7330dcec3
1 changed files with 20 additions and 9 deletions
|
@ -11,7 +11,22 @@ export default abstract class BadgeCache {
|
|||
const urlBadges = new FunkyArray<string, Badge>();
|
||||
const goalBadges = new FunkyArray<string, Badge>();
|
||||
for (const badge of badges) {
|
||||
const urlParts = badge.ForUrl.split("://");
|
||||
if (badge.ForUrl.includes(",")) {
|
||||
const urls = badge.ForUrl.replaceAll(" ", "").split(",");
|
||||
for (const url of urls) {
|
||||
this.processUri(url, badge, goalBadges, urlBadges);
|
||||
}
|
||||
} else {
|
||||
this.processUri(badge.ForUrl, badge, goalBadges, urlBadges);
|
||||
}
|
||||
}
|
||||
|
||||
BadgeCache.UrlBadges = urlBadges;
|
||||
BadgeCache.GoalBadges = goalBadges;
|
||||
}
|
||||
|
||||
private static processUri(uri:string, badge: Badge, goalBadges: FunkyArray<string, Badge>, urlBadges: FunkyArray<string, Badge>) {
|
||||
const urlParts = uri.split("://");
|
||||
let url = urlParts[1].replace("www.", "").toLowerCase().replace(".htm", "").replace(".html", "");
|
||||
if (url.endsWith("/index")) {
|
||||
url = url.replace("/index", "/");
|
||||
|
@ -23,8 +38,4 @@ export default abstract class BadgeCache {
|
|||
urlBadges.set(url, badge);
|
||||
}
|
||||
}
|
||||
|
||||
BadgeCache.UrlBadges = urlBadges;
|
||||
BadgeCache.GoalBadges = goalBadges;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue