Skip to content

Commit 73caf83

Browse files
v 2.7.1 Fix an issue that '#' is not included in the 'onlyUri' property
1 parent 48dae5c commit 73caf83

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

dist/extract-normalize-urls.bundle.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "extract-normalize-urls",
3-
"version": "2.6.0",
3+
"version": "2.7.0",
44
"description": "Extract and normalize urls, fuzzy urls, urls without protocols, uris in natural language texts.",
55
"main": "src/entry.js",
66
"scripts": {

public/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,8 @@ <h3>TextArea (recommended)</h3>
354354
}
355355

356356
start();
357-
console.log('final_3_2 : ' + JSON.stringify(Pattern.UrlArea.parseUrl("http://abc.def:9094/park/noon"), null, 2));
358-
console.log('final_3_3 : ' + JSON.stringify(Pattern.UrlArea.normalizeUrl("://abc.jppp:9091 /park/noon"), null, 2));
357+
console.log('final_3_2 : ' + JSON.stringify(Pattern.UrlArea.parseUrl("http://abc.def:9094#park/noon"), null, 2));
358+
console.log('final_3_3 : ' + JSON.stringify(Pattern.UrlArea.normalizeUrl("://abc.jppp:9091#park/noon"), null, 2));
359359
//console.log('final_5 : ' + JSON.stringify(Pattern.TextArea.extractCertainUris(textStr1, [['{number}', 'kak'], ['nice','guy'],['abc', '{number}']], true), null, 2));
360360
// console.log('final_3 : ' + JSON.stringify(Pattern.XmlArea.extractAllUrls(xmlStr), null, 2));
361361
/*

src/service.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ const Url = {
550550

551551

552552
// URI
553-
let rx4 = new RegExp('\\/(?:.|[\\n\\r\\t\\s])*$', 'gi');
553+
let rx4 = new RegExp('[#/](?:.|[\\n\\r\\t\\s])*$', 'gi');
554554
let match4 = {};
555555
while ((match4 = rx4.exec(modified_url)) !== null) {
556556
obj['onlyUri'] = match4[0];
@@ -833,14 +833,14 @@ const Url = {
833833
}
834834

835835
// 5. Separate uri
836-
let rx2 = new RegExp('\\/(?:.|[\\n\\r\\t\\s])*$', 'gi');
836+
let rx2 = new RegExp('[#/](?:.|[\\n\\r\\t\\s])*$', 'gi');
837837
let match2 = {};
838838
while ((match2 = rx2.exec(url)) !== null) {
839839
obj['onlyUri'] = match2[0];
840840
}
841841
url = url.replace(rx2, '');
842842

843-
if (obj['onlyUri'] === "/") {
843+
if (/^[#/]+$/.test(obj['onlyUri'])) {
844844
obj['onlyUri'] = null;
845845
}
846846

@@ -930,7 +930,7 @@ const Url = {
930930

931931
} else if (obj['onlyUri'] !== null && obj['onlyParams'] === null) {
932932

933-
let rm_part_matches = new RegExp('\\/([^/\\n\\r\\t\\s]+?)(' + Pattern.Ancestors.no_lang_char_num + '+)$', 'gi').exec(obj['url']);
933+
let rm_part_matches = new RegExp('[#/]([^/\\n\\r\\t\\s]+?)(' + Pattern.Ancestors.no_lang_char_num + '+)$', 'gi').exec(obj['url']);
934934

935935
//console.log(obj['url'] + ' : ' + rm_part_matches[1]);
936936

0 commit comments

Comments
 (0)