Skip to content

Commit c92df18

Browse files
Lexis+: normalize helper per code review
1 parent d6c0b9e commit c92df18

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

Lexis+.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,16 @@
3535
***** END LICENSE BLOCK *****
3636
*/
3737

38-
function detectWeb(doc, _url, citation) {
39-
let title = (doc.title || "")
38+
function normalizeTitle(str) {
39+
return (str || "")
4040
.replace(/\bpart\s+\d+\s+of\s+\d+\b/ig, "")
4141
.replace(/\s{2,}/g, " ")
4242
.replace(/\s*,\s*$/, "")
4343
.trim();
44+
}
45+
46+
function detectWeb(doc, _url, citation) {
47+
let title = normalizeTitle(doc.title);
4448
let activeCitation = citation || text(doc, 'span.active-reporter') || "";
4549

4650
if (title.includes("results")) {
@@ -136,11 +140,7 @@ async function scrape(doc, url) {
136140
}
137141
else if (itemType == "statute") {
138142
var newStatute = new Zotero.Item("statute");
139-
title = title
140-
.replace(/\bpart\s+\d+\s+of\s+\d+\b/ig, "")
141-
.replace(/\s{2,}/g, " ")
142-
.replace(/\s*,\s*$/, "")
143-
.trim();
143+
title = normalizeTitle(title);
144144

145145
//newStatute.url = doc.location.href; // Disabled for style reasons
146146

@@ -276,8 +276,12 @@ var testCases = [
276276
{
277277
"type": "web",
278278
"url": "https://plus.lexis.com/document?pdmfid=1530671&pddocfullpath=%2Fshared%2Fdocument%2Fcases%2Furn%3AcontentItem%3A3S4X-KM50-003B-H00B-00000-00&pdcontentcomponentid=6443&ecomp=b7ttk&earg=pdsf&prid=94e1506b-a61a-4690-8fb2-9c7a5057fb3e&crid=d86ab457-174d-47e7-befa-cc5816563a0d&pdsdr=true#/0f459ab4-7325-42c6-9f62-33f772dc07e8",
279-
"detectedItemType": false,
280-
"items": []
279+
"detectedItemType": "case",
280+
"items": [
281+
{
282+
"itemType": "case"
283+
}
284+
]
281285
}
282286
]
283287
/** END TEST CASES **/

0 commit comments

Comments
 (0)