@@ -66,4 +66,55 @@ describe('escaped characters', () => {
6666}` ;
6767 assertEqual ( input , expected ) ;
6868 } ) ;
69+ } ) ;
70+
71+ describe ( 'forward slash escape sequences' , ( ) => {
72+ it ( 'should decode \\/ escape sequences to forward slashes' , ( ) => {
73+ const input = '{"url":"https:\\/\\/example.com\\/api\\/v1"}' ;
74+ const expected = `{
75+ "url": "https://example.com/api/v1"
76+ }` ;
77+ assertEqual ( input , expected ) ;
78+ } ) ;
79+
80+ it ( 'should handle unescaped forward slashes correctly' , ( ) => {
81+ const input = '{"url":"https://example.com/api/v1"}' ;
82+ const expected = `{
83+ "url": "https://example.com/api/v1"
84+ }` ;
85+ assertEqual ( input , expected ) ;
86+ } ) ;
87+
88+ it ( 'should handle forward slashes mixed with other escape sequences' , ( ) => {
89+ const input = '{"text":"line1\\npath\\/to\\/file\\ttab","unicode":"\\u4e16\\u754c\\/path"}' ;
90+ const expected = `{
91+ "text": "line1\\npath/to/file\\ttab",
92+ "unicode": "世界/path"
93+ }` ;
94+ assertEqual ( input , expected ) ;
95+ } ) ;
96+
97+ it ( 'should handle a single escaped forward slash' , ( ) => {
98+ const input = '{"slash":"\\/"}' ;
99+ const expected = `{
100+ "slash": "/"
101+ }` ;
102+ assertEqual ( input , expected ) ;
103+ } ) ;
104+
105+ it ( 'should handle multiple consecutive escaped forward slashes' , ( ) => {
106+ const input = '{"path":"\\/\\/network\\/share"}' ;
107+ const expected = `{
108+ "path": "//network/share"
109+ }` ;
110+ assertEqual ( input , expected ) ;
111+ } ) ;
112+
113+ it ( 'should handle escaped forward slash at end of string' , ( ) => {
114+ const input = '{"url":"https://example.com\\/"}' ;
115+ const expected = `{
116+ "url": "https://example.com/"
117+ }` ;
118+ assertEqual ( input , expected ) ;
119+ } ) ;
69120} ) ;
0 commit comments