Skip to content

Commit 2ec89cf

Browse files
committed
Fix to remove support for TLDs with 1 character
Closes: GH-4.
1 parent 7fb9a05 commit 2ec89cf

File tree

4 files changed

+81
-11
lines changed

4 files changed

+81
-11
lines changed

Diff for: index.js

+5
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ export default function retextSyntaxUrls() {
147147
}
148148
}
149149

150+
// Exit if the TLD is only 1 character long.
151+
if (toString(siblings.slice(index + 1, end + 1)).length === 1) {
152+
return
153+
}
154+
150155
/** @type {Source} */
151156
const replacement = {type: 'SourceNode', value: toString(nodes)}
152157
const initial = pointStart(nodes[0])

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"dependencies": {
3636
"@types/nlcst": "^1.0.0",
3737
"@types/unist": "^2.0.0",
38-
"ccount": "^2.0.1",
38+
"ccount": "^2.0.0",
3939
"nlcst-to-string": "^3.0.0",
4040
"unified": "^10.0.0",
4141
"unist-util-modify-children": "^3.0.0",

Diff for: test/fixtures/eg/input.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
(e.g. dmeshuang@yahoo.com)
1+
(e.g. xxxxxxxxx@yahoo.com)

Diff for: test/fixtures/eg/output.json

+74-9
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"type": "SentenceNode",
99
"children": [
1010
{
11-
"type": "SourceNode",
12-
"value": "(e.g",
11+
"type": "PunctuationNode",
12+
"value": "(",
1313
"position": {
1414
"start": {
1515
"line": 1,
@@ -18,19 +18,84 @@
1818
},
1919
"end": {
2020
"line": 1,
21-
"column": 5,
22-
"offset": 4
21+
"column": 2,
22+
"offset": 1
2323
}
2424
}
2525
},
2626
{
27-
"type": "PunctuationNode",
28-
"value": ".",
27+
"type": "WordNode",
28+
"children": [
29+
{
30+
"type": "TextNode",
31+
"value": "e",
32+
"position": {
33+
"start": {
34+
"line": 1,
35+
"column": 2,
36+
"offset": 1
37+
},
38+
"end": {
39+
"line": 1,
40+
"column": 3,
41+
"offset": 2
42+
}
43+
}
44+
},
45+
{
46+
"type": "PunctuationNode",
47+
"value": ".",
48+
"position": {
49+
"start": {
50+
"line": 1,
51+
"column": 3,
52+
"offset": 2
53+
},
54+
"end": {
55+
"line": 1,
56+
"column": 4,
57+
"offset": 3
58+
}
59+
}
60+
},
61+
{
62+
"type": "TextNode",
63+
"value": "g",
64+
"position": {
65+
"start": {
66+
"line": 1,
67+
"column": 4,
68+
"offset": 3
69+
},
70+
"end": {
71+
"line": 1,
72+
"column": 5,
73+
"offset": 4
74+
}
75+
}
76+
},
77+
{
78+
"type": "PunctuationNode",
79+
"value": ".",
80+
"position": {
81+
"start": {
82+
"line": 1,
83+
"column": 5,
84+
"offset": 4
85+
},
86+
"end": {
87+
"line": 1,
88+
"column": 6,
89+
"offset": 5
90+
}
91+
}
92+
}
93+
],
2994
"position": {
3095
"start": {
3196
"line": 1,
32-
"column": 5,
33-
"offset": 4
97+
"column": 2,
98+
"offset": 1
3499
},
35100
"end": {
36101
"line": 1,
@@ -57,7 +122,7 @@
57122
},
58123
{
59124
"type": "SourceNode",
60-
"value": "dmeshuang@yahoo.com",
125+
"value": "xxxxxxxxx@yahoo.com",
61126
"position": {
62127
"start": {
63128
"line": 1,

0 commit comments

Comments
 (0)