11import { afterEach , describe , expect , it } from 'vitest'
22import {
3- decodePathSegment ,
3+ decodePath ,
44 deepEqual ,
55 isPlainArray ,
66 replaceEqualDeep ,
@@ -498,14 +498,14 @@ describe('deepEqual', () => {
498498 } )
499499} )
500500
501- describe ( 'decodePathSegment ' , ( ) => {
501+ describe ( 'decodePath ' , ( ) => {
502502 it ( 'should decode a path segment with no ignored items existing' , ( ) => {
503503 const itemsToCheck = [ '%25' , '%5C' ]
504504 const stringToCheck =
505505 'https://mozilla.org/?x=%D1%88%D0%B5%D0%BB%D0%BB%D1%8B'
506506 const expectedResult = 'https://mozilla.org/?x=шеллы'
507507
508- const result = decodePathSegment ( stringToCheck , itemsToCheck )
508+ const result = decodePath ( stringToCheck , itemsToCheck )
509509
510510 expect ( result ) . toBe ( expectedResult )
511511 } )
@@ -516,7 +516,7 @@ describe('decodePathSegment', () => {
516516 'https://mozilla.org/?x=%25%D1%88%D0%B5%5C%D0%BB%D0%BB%D1%8B'
517517 const expectedResult = 'https://mozilla.org/?x=%25ше\\ллы'
518518
519- const result = decodePathSegment ( stringToCheck , itemsToCheck )
519+ const result = decodePath ( stringToCheck , itemsToCheck )
520520
521521 expect ( result ) . toBe ( expectedResult )
522522 } )
@@ -527,14 +527,14 @@ describe('decodePathSegment', () => {
527527 'https://mozilla.org/?x=%25%D1%88%D0%B5%D0%BB%D0%BB%D1%8B'
528528 let expectedResult = 'https://mozilla.org/?x=%25шеллы'
529529
530- let result = decodePathSegment ( stringToCheck , itemsToCheck )
530+ let result = decodePath ( stringToCheck , itemsToCheck )
531531
532532 expect ( result ) . toBe ( expectedResult )
533533
534534 stringToCheck = 'https://mozilla.org/?x=%D1%88%D0%B5%5C%D0%BB%D0%BB%D1%8B'
535535 expectedResult = 'https://mozilla.org/?x=ше%5Cллы'
536536
537- result = decodePathSegment ( stringToCheck , itemsToCheck )
537+ result = decodePath ( stringToCheck , itemsToCheck )
538538
539539 expect ( result ) . toBe ( expectedResult )
540540 } )
@@ -545,14 +545,14 @@ describe('decodePathSegment', () => {
545545 'https://mozilla.org/?x=%5C%D1%88%D0%B5%D0%BB%D0%BB%D1%8B'
546546 let expectedResult = 'https://mozilla.org/?x=%5Cшеллы'
547547
548- let result = decodePathSegment ( stringToCheck , itemsToCheck )
548+ let result = decodePath ( stringToCheck , itemsToCheck )
549549
550550 expect ( result ) . toBe ( expectedResult )
551551
552552 stringToCheck = 'https://mozilla.org/?x=%D1%88%D0%B5%5C%D0%BB%D0%BB%D1%8B'
553553 expectedResult = 'https://mozilla.org/?x=ше%5Cллы'
554554
555- result = decodePathSegment ( stringToCheck , itemsToCheck )
555+ result = decodePath ( stringToCheck , itemsToCheck )
556556
557557 expect ( result ) . toBe ( expectedResult )
558558 } )
@@ -563,7 +563,7 @@ describe('decodePathSegment', () => {
563563 'https://mozilla.org/?x=%25%D1%88%D0%B5%5C%D0%BB%D0%BB%D1%8B'
564564 const expectedResult = 'https://mozilla.org/?x=%25ше%5Cллы'
565565
566- const result = decodePathSegment ( stringToCheck , itemsToCheck )
566+ const result = decodePath ( stringToCheck , itemsToCheck )
567567
568568 expect ( result ) . toBe ( expectedResult )
569569 } )
@@ -573,42 +573,42 @@ describe('decodePathSegment', () => {
573573 'https://mozilla.org/?x=%25%D1%88%D0%B5%5C%D0%BB%D0%BB%D1%8B%2F'
574574 const expectedResult = 'https://mozilla.org/?x=%25ше%5Cллы%2F'
575575
576- const result = decodePathSegment ( stringToCheck )
576+ const result = decodePath ( stringToCheck )
577577
578578 expect ( result ) . toBe ( expectedResult )
579579 } )
580580
581581 it ( 'should handle malformed percent-encodings gracefully' , ( ) => {
582582 const stringToCheck = 'path%ZZ%D1%88test%5C%C3%A9'
583583 // Malformed sequences should remain as-is, valid ones decoded
584- const result = decodePathSegment ( stringToCheck )
584+ const result = decodePath ( stringToCheck )
585585 expect ( result ) . toBe ( `path%ZZ%D1%88test%5Cé` )
586586 } )
587587
588588 it ( 'should return empty string unchanged' , ( ) => {
589- expect ( decodePathSegment ( '' ) ) . toBe ( '' )
589+ expect ( decodePath ( '' ) ) . toBe ( '' )
590590 } )
591591
592592 it ( 'should return strings without encoding unchanged' , ( ) => {
593593 const stringToCheck = 'plain-text-path'
594- expect ( decodePathSegment ( stringToCheck ) ) . toBe ( stringToCheck )
594+ expect ( decodePath ( stringToCheck ) ) . toBe ( stringToCheck )
595595 } )
596596
597597 it ( 'should handle consecutive ignored characters' , ( ) => {
598598 const stringToCheck = 'test%25%25end'
599599 const expectedResult = 'test%25%25end'
600- expect ( decodePathSegment ( stringToCheck ) ) . toBe ( expectedResult )
600+ expect ( decodePath ( stringToCheck ) ) . toBe ( expectedResult )
601601 } )
602602
603603 it ( 'should handle multiple ignored items of the same type with varying case' , ( ) => {
604604 const stringToCheck = '/params-ps/named/foo%2Fabc/c%2Fh'
605605 const expectedResult = '/params-ps/named/foo%2Fabc/c%2Fh'
606- expect ( decodePathSegment ( stringToCheck ) ) . toBe ( expectedResult )
606+ expect ( decodePath ( stringToCheck ) ) . toBe ( expectedResult )
607607
608608 const stringToCheckWithLowerCase = '/params-ps/named/foo%2Fabc/c%5C%2f%5cAh'
609609 const expectedResultWithLowerCase =
610610 '/params-ps/named/foo%2Fabc/c%5C%2F%5CAh'
611- expect ( decodePathSegment ( stringToCheckWithLowerCase ) ) . toBe (
611+ expect ( decodePath ( stringToCheckWithLowerCase ) ) . toBe (
612612 expectedResultWithLowerCase ,
613613 )
614614 } )
0 commit comments