浏览代码

Increased test code coverage. Deleted code paths that were never used.

Szymon Kupś 10 年之前
父节点
当前提交
4b0413e38d
共有 2 个文件被更改,包括 11 次插入7 次删除
  1. 3 7
      dev/tasks/utils/git.js
  2. 8 0
      dev/tests/git.js

+ 3 - 7
dev/tasks/utils/git.js

@@ -38,7 +38,7 @@ module.exports = {
 	 * @returns {String} urlInfo.branch
 	 */
 	parseRepositoryUrl( url ) {
-		const regexp = /^((?:git@|http[s]?:\/\/)github\.com(?:\/|:))?(([\w-]+)\/([\w-]+(?:\.git)?))(?:#([\w-/]+))?$/;
+		const regexp = /^((?:git@|http[s]?:\/\/)github\.com(?:\/|:))?(([\w-]+)\/([\w-]+(?:\.git)?))(?:#([\w-\/]+))?$/;
 		const match = url.match( regexp );
 		let server;
 		let repository;
@@ -52,14 +52,10 @@ module.exports = {
 
 		server = match[ 1 ] || 'https://github.com/';
 		repository = match[ 2 ];
-		user = match[ 3 ] || '';
-		name = match[ 4 ] || '';
+		user = match[ 3 ];
+		name = match[ 4 ];
 		branch = match[ 5 ] || 'master';
 
-		if ( !repository || !user || !name ) {
-			return null;
-		}
-
 		name = /\.git$/.test( name ) ? name.slice( 0, -4 ) : name;
 
 		return {

+ 8 - 0
dev/tests/git.js

@@ -104,6 +104,14 @@ describe( 'utils', () => {
 				expect( urlInfo.name ).to.equal( 'ckeditor5-core' );
 				expect( urlInfo.branch ).to.equal( 'new-feature' );
 			} );
+
+			it( 'should return null if GitHub URL is not valid', () => {
+				let urlInfo = git.parseRepositoryUrl( 'https://ckeditor.com' );
+				expect( urlInfo ).to.equal( null );
+
+				urlInfo = git.parseRepositoryUrl( 'https://github.com/info.html' );
+				expect( urlInfo ).to.equal( null );
+			} );
 		} );
 
 		describe( 'cloneRepository', () => {