File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -1708,6 +1708,31 @@ describe('util', () => {
17081708 } ) ;
17091709
17101710 } ) ;
1711+
1712+ describe ( 'virtual:/ paths' , ( ) => {
1713+ it ( 'preserves virtual:/ prefix on windows' , ( ) => {
1714+ isWindows = true ;
1715+ test ( 'virtual:/ButtonPrimary.brs' , 'virtual:/buttonprimary.brs' ) ;
1716+ test ( 'virtual:\\ButtonPrimary.brs' , 'virtual:/buttonprimary.brs' ) ;
1717+ } ) ;
1718+
1719+ it ( 'preserves virtual:/ prefix on unix' , ( ) => {
1720+ isWindows = false ;
1721+ test ( 'virtual:/ButtonPrimary.brs' , 'virtual:/buttonprimary.brs' ) ;
1722+ test ( 'virtual:\\ButtonPrimary.brs' , 'virtual:/buttonprimary.brs' ) ;
1723+ } ) ;
1724+
1725+ it ( 'normalizes consecutive slashes in virtual paths' , ( ) => {
1726+ isWindows = true ;
1727+ test ( 'virtual://one//two.brs' , 'virtual:/one/two.brs' ) ;
1728+ isWindows = false ;
1729+ test ( 'virtual://one//two.brs' , 'virtual:/one/two.brs' ) ;
1730+ } ) ;
1731+
1732+ it ( 'lowercases virtual path content' , ( ) => {
1733+ test ( 'virtual:/UPPER/CasePath.brs' , 'virtual:/upper/casepath.brs' ) ;
1734+ } ) ;
1735+ } ) ;
17111736 } ) ;
17121737
17131738 describe ( 'isClassUsedAsFunction' , ( ) => {
Original file line number Diff line number Diff line change @@ -1822,6 +1822,14 @@ export class Util {
18221822 return thePath ;
18231823 }
18241824
1825+ //handle `virtual:/` paths specially - just normalize slashes, don't use path.normalize which would mangle the `virtual:` prefix
1826+ if ( / ^ v i r t u a l : [ \/ \\ ] / i. test ( thePath ) ) {
1827+ // Strip the `virtual:` prefix, normalize slashes, then re-add the prefix
1828+ thePath = 'virtual:/' + thePath . slice ( 8 ) . replace ( / ^ [ \/ \\ ] + / , '' ) . replace ( / [ \/ \\ ] + / g, '/' ) . toLowerCase ( ) ;
1829+ this . standardizePathCache . set ( originalPath , thePath ) ;
1830+ return thePath ;
1831+ }
1832+
18251833 //windows path.normalize will convert all slashes to backslashes and remove duplicates
18261834 if ( this . isWindows ) {
18271835 thePath = path . win32 . normalize ( thePath ) ;
You can’t perform that action at this time.
0 commit comments