소스 검색

Fix tests (again)

Garrett Johnson 5 년 전
부모
커밋
5677d24649
2개의 변경된 파일11개의 추가작업 그리고 28개의 파일을 삭제
  1. 2 2
      src/utilities/urlJoin.js
  2. 9 26
      test/urlJoin.test.js

+ 2 - 2
src/utilities/urlJoin.js

@@ -18,7 +18,7 @@ export function urlJoin( ...args ) {
 
 	if ( lastRoot === - 1 ) {
 
-		return path.join( ...args );
+		return path.join( ...args ).replace( /\\/g, '/' );
 
 	} else {
 
@@ -26,7 +26,7 @@ export function urlJoin( ...args ) {
 		const protocol = parts[ 0 ].match( protocolRegex )[ 0 ];
 		parts[ 0 ] = parts[ 0 ].substring( protocol.length );
 
-		return path.normalize( protocol + path.join( ...parts ) );
+		return ( protocol + path.join( ...parts ) ).replace( /\\/g, '/' );
 
 	}
 

+ 9 - 26
test/urlJoin.test.js

@@ -1,4 +1,3 @@
-import path from 'path';
 import { urlJoin } from '../src/utilities/urlJoin.js';
 
 describe( 'urlJoin', () => {
@@ -7,21 +6,15 @@ describe( 'urlJoin', () => {
 
 		expect(
 			urlJoin( 'path', 'to', 'file.json' )
-		).toBe(
-			path.normalize( 'path\\to\\file.json' )
-		);
+		).toBe( 'path/to/file.json' );
 
 		expect(
-			urlJoin( 'path//', 'to\\other\\', 'file.json' )
-		).toBe(
-			path.normalize( 'path\\to\\other\\file.json' )
-		);
+			urlJoin( 'path//', 'to/other/', 'file.json' )
+		).toBe( 'path/to/other/file.json' );
 
 		expect(
 			urlJoin( '//path', 'to', 'file.json' )
-		).toBe(
-			path.normalize( '\\\\path\\to\\file.json' )
-		);
+		).toBe( '//path/to/file.json' );
 
 	} );
 
@@ -29,33 +22,23 @@ describe( 'urlJoin', () => {
 
 		expect(
 			urlJoin( 'http://path', 'to', 'file.json' )
-		).toBe(
-			path.normalize( 'http:\\\\path\\to\\file.json' )
-		);
+		).toBe( 'http://path/to/file.json' );
 
 		expect(
 			urlJoin( 'http://path', 'http://path2', 'to', 'file.json' )
-		).toBe(
-			path.normalize( 'http:\\\\path2\\to\\file.json' )
-		);
+		).toBe( 'http://path2/to/file.json' );
 
 		expect(
 			urlJoin( 'https://path', 'to', 'file.json' )
-		).toBe(
-			path.normalize( 'https:\\\\path\\to\\file.json' )
-		);
+		).toBe( 'https://path/to/file.json' );
 
 		expect(
 			urlJoin( 'ftp://path', 'to', 'file.json' )
-		).toBe(
-			path.normalize( 'ftp:\\\\path\\to\\file.json' )
-		);
+		).toBe( 'ftp://path/to/file.json' );
 
 		expect(
 			urlJoin( 'ftp://http://path', 'to', 'file.json' )
-		).toBe(
-			path.normalize( 'ftp:\\\\http:\\path\\to\\file.json' )
-		);
+		).toBe( 'ftp://http:/path/to/file.json' );
 
 	} );