@@ -674,7 +674,36 @@ describe('flattenId', () => {
674674 const id = 'ravelinjs/core+track+encrypt+promise'
675675 const result = flattenId ( id )
676676 expect ( result ) . not . toContain ( '+' )
677- expect ( result ) . toBe ( 'ravelinjs_core_____track_____encrypt_____promise' )
677+ expect ( result ) . toBe ( 'ravelinjs_core_02b_track_02b_encrypt_02b_promise' )
678+ } )
679+
680+ test ( 'escape _' , ( ) => {
681+ expect ( flattenId ( 'foo_bar' ) ) . toMatchInlineSnapshot ( `"foo___bar"` )
682+ expect ( flattenId ( 'foo__bar' ) ) . toMatchInlineSnapshot ( `"foo____bar"` )
683+ expect ( flattenId ( 'foo___bar' ) ) . toMatchInlineSnapshot ( `"foo_____bar"` )
684+ expect ( flattenId ( 'foo____bar' ) ) . toMatchInlineSnapshot ( `"foo______bar"` )
685+ } )
686+
687+ test ( 'escape /' , ( ) => {
688+ expect ( flattenId ( 'foo/bar' ) ) . toMatchInlineSnapshot ( `"foo_bar"` )
689+ } )
690+
691+ test ( 'escape .' , ( ) => {
692+ expect ( flattenId ( 'foo.bar' ) ) . toMatchInlineSnapshot ( `"foo__bar"` )
693+ } )
694+
695+ test ( 'escape invalid URL path chars' , ( ) => {
696+ expect ( flattenId ( 'foo#bar' ) ) . toMatchInlineSnapshot ( `"foo_023_bar"` )
697+ expect ( flattenId ( 'foo$bar' ) ) . toMatchInlineSnapshot ( `"foo_024_bar"` )
698+ expect ( flattenId ( 'foo*bar' ) ) . toMatchInlineSnapshot ( `"foo_02a_bar"` )
699+ expect ( flattenId ( 'foo+bar' ) ) . toMatchInlineSnapshot ( `"foo_02b_bar"` )
700+ } )
701+
702+ test ( 'escape nested IDs' , ( ) => {
703+ expect ( flattenId ( 'foo>bar' ) ) . toMatchInlineSnapshot ( `"foo_n_bar"` )
704+ expect ( flattenId ( 'foo >bar' ) ) . toMatchInlineSnapshot ( `"foo_n_bar"` )
705+ expect ( flattenId ( 'foo> bar' ) ) . toMatchInlineSnapshot ( `"foo_n_bar"` )
706+ expect ( flattenId ( 'foo > bar' ) ) . toMatchInlineSnapshot ( `"foo_n_bar"` )
678707 } )
679708} )
680709
0 commit comments