File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -197,6 +197,18 @@ describe('renderMessage', () => {
197
197
) ;
198
198
} ) ;
199
199
200
+ it ( 'renders a wire deeplink with config url' , ( ) => {
201
+ expect ( renderMessage ( 'wire://access/?config=https://test.com/deeplink.json' ) ) . toBe (
202
+ '<a href="wire://access/?config=https://test.com/deeplink.json" target="_blank" rel="nofollow noopener noreferrer" data-uie-name="wire-deep-link">wire://access/?config=https://test.com/deeplink.json</a>' ,
203
+ ) ;
204
+ } ) ;
205
+
206
+ it ( 'renders a wire deeplink with config url with alias' , ( ) => {
207
+ expect ( renderMessage ( '[deeplink](wire://access/?config=https://test.com/deeplink.json)' ) ) . toBe (
208
+ '<a href="wire://access/?config=https://test.com/deeplink.json" target="_blank" rel="nofollow noopener noreferrer" data-uie-name="wire-deep-link">deeplink</a>' ,
209
+ ) ;
210
+ } ) ;
211
+
200
212
it ( 'renders a link from markdown notation with formatting' , ( ) => {
201
213
expect ( renderMessage ( '[**doop**](http://www.example.com)' ) ) . toBe (
202
214
'<a href="http://www.example.com" target="_blank" rel="nofollow noopener noreferrer" data-md-link="true" data-uie-name="markdown-link"><strong>doop</strong></a>' ,
Original file line number Diff line number Diff line change @@ -59,6 +59,26 @@ const markdownit = new MarkdownIt('zero', {
59
59
'blockquote' ,
60
60
] ) ;
61
61
62
+ markdownit . linkify . add ( 'wire:' , {
63
+ validate : ( text , pos ) => {
64
+ // Typical linkify schema: valid url chars to first whitespace or control char
65
+ const tail = text . slice ( pos ) ;
66
+
67
+ // A simple matcher: up to the first space, <, or a parenthesis.
68
+ const match = / ^ [ ^ \s < > ( ) ] + / . exec ( tail ) ;
69
+ if ( match ) {
70
+ return match [ 0 ] . length ;
71
+ }
72
+ return 0 ;
73
+ } ,
74
+ normalize : match => {
75
+ // match.url has the form ‘wire:/...’; replace it with ‘wire://...’ if needed
76
+ if ( match . url . startsWith ( 'wire:/' ) && ! match . url . startsWith ( 'wire://' ) ) {
77
+ match . url = match . url . replace ( 'wire:/' , 'wire://' ) ;
78
+ }
79
+ } ,
80
+ } ) ;
81
+
62
82
const originalFenceRule = markdownit . renderer . rules . fence ! ;
63
83
64
84
markdownit . renderer . rules . heading_open = ( tokens , idx ) => {
You can’t perform that action at this time.
0 commit comments