@@ -15,54 +15,50 @@ const processMarkdown = async (markdown: string, options: Record<string, any> =
15
15
return result . toString ( ) ;
16
16
} ;
17
17
18
+ const normalizeString = ( str : string ) => str . trim ( ) ;
19
+
18
20
const CorePassHandlers = suite ( 'CorePass handlers' ) ;
19
21
20
22
CorePassHandlers ( 'Transforms CoreID link' , async ( ) => {
21
23
const input = '[cb7147879011ea207df5b35a24ca6f0859dcfb145999@coreid]' ;
22
- const output = await processMarkdown ( input , { enableIcanCheck : true } ) ;
23
- assert . match ( output , / \[ C B 7 1 … 5 9 9 9 @ c o r e i d \] \( c o r e p a s s : c b 7 1 4 7 8 7 9 0 1 1 e a 2 0 7 d f 5 b 3 5 a 2 4 c a 6 f 0 8 5 9 d c f b 1 4 5 9 9 9 " C B 7 1 … 5 9 9 9 " \) / ) ;
24
+ const output = normalizeString ( await processMarkdown ( input , { enableIcanCheck : true } ) ) ;
25
+ const expected = '[CB71…5999@coreid](corepass:cb7147879011ea207df5b35a24ca6f0859dcfb145999 "CB7147879011EA207DF5B35A24CA6F0859DCFB145999")' ;
26
+ assert . is ( output , expected ) ;
24
27
} ) ;
25
28
26
29
CorePassHandlers ( 'Transforms CoreID link w/ bad checksum & w/o ican check' , async ( ) => {
27
30
const input = '[!cb7247879011ea207df5b35a24ca6f0859dcfb145999@coreid]' ;
28
- const output = await processMarkdown ( input , { enableIcanCheck : true } ) ;
29
- assert . match ( output , / \[ C B 7 2 … 5 9 9 9 @ c o r e i d \] \( c o r e p a s s : c b 7 2 4 7 8 7 9 0 1 1 e a 2 0 7 d f 5 b 3 5 a 2 4 c a 6 f 0 8 5 9 d c f b 1 4 5 9 9 9 " C B 7 2 … 5 9 9 9 " \) / ) ;
30
- } ) ;
31
-
32
- CorePassHandlers ( 'Transforms CoreID link w/ bad checksum & w/ ican check' , async ( ) => {
33
- const input = '[cb7247879011ea207df5b35a24ca6f0859dcfb145999@coreid]' ;
34
- const output = await processMarkdown ( input , { enableIcanCheck : true } ) ;
35
- assert . match ( output , / ~ ~ C B 7 2 … 5 9 9 9 @ c o r e i d ~ ~ / ) ;
31
+ const output = normalizeString ( await processMarkdown ( input , { enableIcanCheck : true } ) ) ;
32
+ const expected = '[CB72…5999@coreid](corepass:cb7247879011ea207df5b35a24ca6f0859dcfb145999 "CB7247879011EA207DF5B35A24CA6F0859DCFB145999")' ;
33
+ assert . is ( output , expected ) ;
36
34
} ) ;
37
35
38
36
CorePassHandlers ( 'Transforms CoreID link as domain pattern' , async ( ) => {
39
37
const input = '[sub.domain.cc@coreid]' ;
40
- const output = await processMarkdown ( input ) ;
41
- assert . match ( output , / \[ s u b .d o m a i n .c c @ c o r e i d \] \( c o r e p a s s : s u b .d o m a i n .c c " s u b .d o m a i n .c c " \) / ) ;
38
+ const output = normalizeString ( await processMarkdown ( input ) ) ;
39
+ const expected = '[sub.domain.cc@coreid](corepass:sub.domain.cc "sub.domain.cc")' ;
40
+ assert . is ( output , expected ) ;
42
41
} ) ;
43
42
44
43
CorePassHandlers ( 'Transforms CoreID link as emoji domain pattern' , async ( ) => {
45
44
const input = '[emoji🎉domain.cc@coreid]' ;
46
- const output = await processMarkdown ( input ) ;
47
- assert . match ( output , / \[ e m o j i 🎉 d o m a i n .c c @ c o r e i d \] \( c o r e p a s s : e m o j i 🎉 d o m a i n .c c " e m o j i 🎉 d o m a i n .c c " \) / ) ;
45
+ const output = normalizeString ( await processMarkdown ( input ) ) ;
46
+ const expected = '[emoji🎉domain.cc@coreid](corepass:emoji🎉domain.cc "emoji🎉domain.cc")' ;
47
+ assert . is ( output , expected ) ;
48
48
} ) ;
49
49
50
50
CorePassHandlers ( 'Transforms CoreID link defined with round brackets' , async ( ) => {
51
51
const input = '[cb7147879011ea207df5b35a24ca6f0859dcfb145999@coreid]' ;
52
- const output = await processMarkdown ( input , { enableIcanCheck : true } ) ;
53
- assert . match ( output , / \[ C B 7 1 … 5 9 9 9 @ c o r e i d \] \( c o r e p a s s : c b 7 1 4 7 8 7 9 0 1 1 e a 2 0 7 d f 5 b 3 5 a 2 4 c a 6 f 0 8 5 9 d c f b 1 4 5 9 9 9 " C B 7 1 … 5 9 9 9 " \) / ) ;
52
+ const output = normalizeString ( await processMarkdown ( input , { enableIcanCheck : true } ) ) ;
53
+ const expected = '[CB71…5999@coreid](corepass:cb7147879011ea207df5b35a24ca6f0859dcfb145999 "CB7147879011EA207DF5B35A24CA6F0859DCFB145999")' ;
54
+ assert . is ( output , expected ) ;
54
55
} ) ;
55
56
56
57
CorePassHandlers ( 'Transforms CoreID link defined with round brackets, w/o ican check and w/ bad checksum' , async ( ) => {
57
58
const input = '[!cb7247879011ea207df5b35a24ca6f0859dcfb145999@coreid]' ;
58
- const output = await processMarkdown ( input , { enableIcanCheck : true } ) ;
59
- assert . match ( output , / \[ C B 7 2 … 5 9 9 9 @ c o r e i d \] \( c o r e p a s s : c b 7 2 4 7 8 7 9 0 1 1 e a 2 0 7 d f 5 b 3 5 a 2 4 c a 6 f 0 8 5 9 d c f b 1 4 5 9 9 9 " C B 7 2 … 5 9 9 9 " \) / ) ;
60
- } ) ;
61
-
62
- CorePassHandlers ( 'Transforms CoreID link defined with round brackets, w/ ican check and w/ bad checksum' , async ( ) => {
63
- const input = '[cb7247879011ea207df5b35a24ca6f0859dcfb145999@coreid]' ;
64
- const output = await processMarkdown ( input , { enableIcanCheck : true } ) ;
65
- assert . match ( output , / ~ ~ C B 7 2 … 5 9 9 9 @ c o r e i d ~ ~ / ) ;
59
+ const output = normalizeString ( await processMarkdown ( input , { enableIcanCheck : true } ) ) ;
60
+ const expected = '[CB72…5999@coreid](corepass:cb7247879011ea207df5b35a24ca6f0859dcfb145999 "CB7247879011EA207DF5B35A24CA6F0859DCFB145999")' ;
61
+ assert . is ( output , expected ) ;
66
62
} ) ;
67
63
68
64
CorePassHandlers . run ( ) ;
0 commit comments