count.js: support data-page-id paths

Closes https://gitlab.com/commento/commento/issues/255
This commit is contained in:
Adhityaa Chandrasekar 2020-01-02 14:02:36 -08:00
parent 15022ba3a0
commit 166599a2c8

View File

@ -61,12 +61,15 @@
href = href.replace(/^.*\/\/[^\/]+/, ""); href = href.replace(/^.*\/\/[^\/]+/, "");
if (href.endsWith("#commento")) { if (href.endsWith("#commento")) {
var path = href.substr(0, href.indexOf("#commento")); var pageId = attrGet(as[i], "data-page-id");
if (path.startsWith(parent.location.host)) { if (pageId === undefined) {
path = path.substr(parent.location.host.length); pageId = href.substr(0, href.indexOf("#commento"));
if (pageId.startsWith(parent.location.host)) {
pageId = pageId.substr(parent.location.host.length);
}
} }
paths.push(path); paths.push(pageId);
doms.push(as[i]); doms.push(as[i]);
} }
} }