diff --git a/server/objects/BadgeCache.ts b/server/objects/BadgeCache.ts index ecdf916..e1c5b7e 100644 --- a/server/objects/BadgeCache.ts +++ b/server/objects/BadgeCache.ts @@ -11,20 +11,31 @@ export default abstract class BadgeCache { const urlBadges = new FunkyArray(); const goalBadges = new FunkyArray(); for (const badge of badges) { - const urlParts = badge.ForUrl.split("://"); - let url = urlParts[1].replace("www.", "").toLowerCase().replace(".htm", "").replace(".html", ""); - if (url.endsWith("/index")) { - url = url.replace("/index", "/"); - } - - if (urlParts[0] === "mp") { - goalBadges.set(url, badge); + if (badge.ForUrl.includes(",")) { + const urls = badge.ForUrl.replaceAll(" ", "").split(","); + for (const url of urls) { + this.processUri(url, badge, goalBadges, urlBadges); + } } else { - urlBadges.set(url, badge); + this.processUri(badge.ForUrl, badge, goalBadges, urlBadges); } } BadgeCache.UrlBadges = urlBadges; BadgeCache.GoalBadges = goalBadges; } + + private static processUri(uri:string, badge: Badge, goalBadges: FunkyArray, urlBadges: FunkyArray) { + const urlParts = uri.split("://"); + let url = urlParts[1].replace("www.", "").toLowerCase().replace(".htm", "").replace(".html", ""); + if (url.endsWith("/index")) { + url = url.replace("/index", "/"); + } + + if (urlParts[0] === "mp") { + goalBadges.set(url, badge); + } else { + urlBadges.set(url, badge); + } + } } \ No newline at end of file