瀏覽代碼

Updated git.parseRepositoryUrl regural expression.

Szymon Kupś 10 年之前
父節點
當前提交
edd1063e88
共有 2 個文件被更改,包括 11 次插入1 次删除
  1. 1 1
      dev/tasks/utils/git.js
  2. 10 0
      dev/tests/git.js

+ 1 - 1
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]?|git):\/\/)github\.com(?:\/|:))?(([\w-]+)\/([\w-]+(?:\.git)?))(?:#([\w-\/]+))?$/;
 		const match = url.match( regexp );
 		let server;
 		let repository;

+ 10 - 0
dev/tests/git.js

@@ -95,6 +95,16 @@ describe( 'utils', () => {
 				expect( urlInfo.branch ).to.equal( 'master' );
 			} );
 
+			it( 'should parse full GitHub URL (git)', () => {
+				const urlInfo = git.parseRepositoryUrl( 'git://github.com/ckeditor/ckeditor5-core.git' );
+
+				expect( urlInfo.server ).to.equal( 'git://github.com/' );
+				expect( urlInfo.repository ).to.equal( 'ckeditor/ckeditor5-core.git' );
+				expect( urlInfo.user ).to.equal( 'ckeditor' );
+				expect( urlInfo.name ).to.equal( 'ckeditor5-core' );
+				expect( urlInfo.branch ).to.equal( 'master' );
+			} );
+
 			it( 'should parse full GitHub URL (git) with provided branch', () => {
 				const urlInfo = git.parseRepositoryUrl( 'git@github.com:ckeditor/ckeditor5-core.git#new-feature' );