8
0
Pārlūkot izejas kodu

AmdUtils.getModulePath() should not process absolute paths. Fixes #69.

Piotrek Koszuliński 10 gadi atpakaļ
vecāks
revīzija
46119bf546
2 mainītis faili ar 13 papildinājumiem un 0 dzēšanām
  1. 7 0
      tests/_utils/amd.js
  2. 6 0
      tests/utils-tests/amd.js

+ 7 - 0
tests/_utils/amd.js

@@ -19,10 +19,17 @@ const utils = {
 	 * * `foo` -> `/ckeditor5/foo/foo.js`
 	 * * `foo/bar` -> `/ckeditor5/foo/bar.js`
 	 *
+	 * If the path is already absolute, then it will be returned without any changes.
+	 *
 	 * @param {String} modulePath The simplified path.
 	 * @returns {String} The real path.
 	 */
 	getModulePath( modulePath ) {
+		// Do nothing – path is already absolute.
+		if ( modulePath.startsWith( '/' ) ) {
+			return modulePath;
+		}
+
 		if ( modulePath.indexOf( '/' ) < 0 ) {
 			modulePath = modulePath + '/' + modulePath;
 		}

+ 6 - 0
tests/utils-tests/amd.js

@@ -27,6 +27,12 @@ describe( 'amdTestUtils', () => {
 
 			expect( path ).to.equal( '/ckeditor5/core/editor.js' );
 		} );
+
+		it( 'does not process an absolute path', () => {
+			const path = getModulePath( '/foo/bar/bom.js' );
+
+			expect( path ).to.equal( '/foo/bar/bom.js' );
+		} );
 	} );
 
 	describe( 'define()', () => {