File tree Expand file tree Collapse file tree
packages/uniorg-parse/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ " uniorg-parse " : patch
3+ ---
4+
5+ Fix link type detection in ` [[ ]] ` links when protocol name occurs in the middle of the URL.
6+
7+ Previously, ` [[my-link:https://blah]] ` was incorrectly detected as ` https ` link type. Now it's correctly recognized as ` fuzzy ` link type.
Original file line number Diff line number Diff line change @@ -2549,6 +2549,24 @@ children:
25492549 children: []
25502550`;
25512551
2552+ exports[`org/parser > links > custom type wrapping a url 1`] = `
2553+ type: "org-data"
2554+ contentsBegin: 0
2555+ contentsEnd: 28
2556+ children:
2557+ - type: "paragraph"
2558+ affiliated: { }
2559+ contentsBegin: 0
2560+ contentsEnd: 28
2561+ children:
2562+ - type: "link"
2563+ format: "bracket"
2564+ linkType: "fuzzy"
2565+ rawLink: "card:https://example.com"
2566+ path: "card:https://example.com"
2567+ children: []
2568+ `;
2569+
25522570exports[`org/parser > links > file link with percents 1`] = `
25532571type: "org-data"
25542572contentsBegin: 0
@@ -2603,6 +2621,24 @@ children:
26032621 children: []
26042622`;
26052623
2624+ exports[`org/parser > links > leading whitespace is not a link type 1`] = `
2625+ type: "org-data"
2626+ contentsBegin: 0
2627+ contentsEnd: 24
2628+ children:
2629+ - type: "paragraph"
2630+ affiliated: { }
2631+ contentsBegin: 0
2632+ contentsEnd: 24
2633+ children:
2634+ - type: "link"
2635+ format: "bracket"
2636+ linkType: "fuzzy"
2637+ rawLink: " https://example.com"
2638+ path: " https://example.com"
2639+ children: []
2640+ `;
2641+
26062642exports[`org/parser > links > link 1`] = `
26072643type: "org-data"
26082644contentsBegin: 0
Original file line number Diff line number Diff line change @@ -480,6 +480,10 @@ I have no :END:`
480480
481481 itParses ( 'https link' , `[[https://example.com/hello]]` ) ;
482482
483+ itParses ( 'custom type wrapping a url' , `[[card:https://example.com]]` ) ;
484+
485+ itParses ( 'leading whitespace is not a link type' , `[[ https://example.com]]` ) ;
486+
483487 itParses (
484488 'multiline description' ,
485489 `[[www.something.com][line1
Original file line number Diff line number Diff line change @@ -2351,7 +2351,7 @@ class Parser {
23512351 return { linkType : 'file' , path : link } ;
23522352 }
23532353 // Explicit type (http, irc, bbdb...).
2354- const m = link . match ( new RegExp ( this . re . linkTypesRe ( ) ) ) ;
2354+ const m = link . match ( new RegExp ( `^ ${ this . re . linkTypesRe ( ) } ` ) ) ;
23552355 if ( m ) {
23562356 return { linkType : m [ 1 ] , path : link . slice ( m [ 0 ] . length ) } ;
23572357 }
You can’t perform that action at this time.
0 commit comments