|
35 | 35 | ***** END LICENSE BLOCK ***** |
36 | 36 | */ |
37 | 37 |
|
38 | | -function detectWeb(doc, _url, citation) { |
39 | | - let title = (doc.title || "") |
| 38 | +function normalizeTitle(str) { |
| 39 | + return (str || "") |
40 | 40 | .replace(/\bpart\s+\d+\s+of\s+\d+\b/ig, "") |
41 | 41 | .replace(/\s{2,}/g, " ") |
42 | 42 | .replace(/\s*,\s*$/, "") |
43 | 43 | .trim(); |
| 44 | +} |
| 45 | + |
| 46 | +function detectWeb(doc, _url, citation) { |
| 47 | + let title = normalizeTitle(doc.title); |
44 | 48 | let activeCitation = citation || text(doc, 'span.active-reporter') || ""; |
45 | 49 |
|
46 | 50 | if (title.includes("results")) { |
@@ -136,11 +140,7 @@ async function scrape(doc, url) { |
136 | 140 | } |
137 | 141 | else if (itemType == "statute") { |
138 | 142 | 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); |
144 | 144 |
|
145 | 145 | //newStatute.url = doc.location.href; // Disabled for style reasons |
146 | 146 |
|
@@ -276,8 +276,12 @@ var testCases = [ |
276 | 276 | { |
277 | 277 | "type": "web", |
278 | 278 | "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 | + ] |
281 | 285 | } |
282 | 286 | ] |
283 | 287 | /** END TEST CASES **/ |
0 commit comments