File tree Expand file tree Collapse file tree 2 files changed +12
-12
lines changed
Expand file tree Collapse file tree 2 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -8,12 +8,17 @@ export default class PathHelper {
88
99 static pathToArray ( path ) {
1010 return this . reverseStr ( path )
11- . split ( / [ / ] (? ! [ \\ ] ) / )
11+ . split ( / [ / ] (? ! [ \\ ] ) | [ / ] (? = \\ \\ ) / )
1212 . map ( value => this . reverseStr ( value ) )
13+ . map ( value => value . replace ( / \\ [ / ] / g, '/' ) )
14+ . map ( value => value . replace ( / \\ \\ / g, '\\' ) )
1315 . reverse ( )
1416 }
1517
1618 static arrayToPath ( array ) {
17- return array . map ( value => value . replace ( / [ / ] / , '\\/' ) ) . join ( '/' )
19+ return array
20+ . map ( value => value . replace ( / \\ / g, '\\\\' ) )
21+ . map ( value => value . replace ( / [ / ] / g, '\\/' ) )
22+ . join ( '/' )
1823 }
1924}
Original file line number Diff line number Diff line change @@ -483,24 +483,19 @@ export default class NextcloudAdapter extends Adapter {
483483 }
484484
485485 static convertPathToTag ( path ) {
486- // We reverse the string and do a negative lookahead, reversing again afterwards
487486 return (
488487 TAG_PREFIX +
489- PathHelper . pathToArray ( path )
490- . map ( str => str . replace ( / > / g, '\\>' ) )
491- . join ( '>' )
488+ path
489+ . replace ( / [ / ] / g, '>' )
492490 . replace ( / % 2 C / g, '%252C' )
493491 . replace ( / , / g, '%2C' )
494492 ) // encodeURIComponent(',') == '%2C'
495493 }
496494
497495 static convertTagToPath ( tag ) {
498- // We reverse the string and split using a negative lookahead, reversing again afterwards
499- return PathHelper . reverseStr ( tag . substr ( TAG_PREFIX . length ) )
500- . split ( / > (? ! [ \\ ] ) / )
501- . reverse ( )
502- . map ( str => PathHelper . reverseStr ( str ) . replace ( / \\ > / g, '>' ) )
503- . join ( '/' )
496+ return tag
497+ . substr ( TAG_PREFIX . length )
498+ . replace ( / > / g, '>' )
504499 . replace ( / % 2 C / g, ',' ) // encodeURIComponent(',') == '%2C'
505500 . replace ( / % 2 5 2 C / g, '%2C' )
506501 }
You can’t perform that action at this time.
0 commit comments