File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,9 +7,10 @@ describe('context object', () => {
77
88 test ( 'context' , async ( ) => {
99 let { context, hasWindow} = await import ( "#js/util/context.js" ) ;
10- expect ( context . path ( 'C:\\test.js' ) ) . toBe ( 'C:/test.js' ) ;
11- expect ( context . path ( '/C:/test.js' ) ) . toBe ( 'C:/test.js' ) ;
12- expect ( context . path ( '/test.js' ) ) . toBe ( '/test.js' ) ;
10+ expect ( context . path ( 'C:\\test.js' ) ) . toBe ( 'file://C:/test.js' ) ;
11+ expect ( context . path ( '/C:/test.js' ) ) . toBe ( 'file://C:/test.js' ) ;
12+ expect ( context . path ( '/test.js' ) ) . toBe ( 'file:///test.js' ) ;
13+ expect ( context . path ( './test.js' ) ) . toBe ( './test.js' ) ;
1314 delete context . path ;
1415 expect ( context ) . toEqual ( { window : window , document : window . document , os : 'Windows' } ) ;
1516 expect ( hasWindow ) . toBe ( true ) ;
Original file line number Diff line number Diff line change @@ -27,7 +27,12 @@ import { context } from '../context.js';
2727declare const System : { import : ( name : string , url ?: string ) => any } ;
2828declare const __dirname : string ;
2929
30- let root = 'file://' + context . path ( __dirname ) . replace ( / \/ [ ^ / ] * \/ [ ^ / ] * $ / , '/' ) ;
30+ let root =
31+ 'file://' +
32+ context
33+ . path ( __dirname )
34+ . replace ( / \/ [ ^ / ] * \/ [ ^ / ] * $ / , '/' )
35+ . replace ( / ^ f i l e : \/ \/ / , '' ) ;
3136
3237if ( ! mathjax . asyncLoad && typeof System !== 'undefined' && System . import ) {
3338 mathjax . asyncLoad = ( name : string ) => {
Original file line number Diff line number Diff line change @@ -75,6 +75,6 @@ export const context = {
7575if ( context . os === 'Windows' ) {
7676 context . path = ( file : string ) =>
7777 file . match ( / ^ [ / \\ ] ? [ a - z A - Z ] : [ / \\ ] / )
78- ? file . replace ( / \\ / g, '/' ) . replace ( / ^ \/ / , '' )
79- : file ;
78+ ? 'file://' + file . replace ( / \\ / g, '/' ) . replace ( / ^ \/ / , '' )
79+ : file . replace ( / ^ \/ / , 'file:///' ) ;
8080}
You can’t perform that action at this time.
0 commit comments