@@ -3,6 +3,49 @@ import { describe, expect, it } from "vite-plus/test";
33import { cloneUrlForProtocol , cloneUrlProtocol } from "./cloneUrl.ts" ;
44
55describe ( "cloneUrlForProtocol" , ( ) => {
6+ it . each ( [
7+ "[email protected] :v3/Fabrikam/Project1/fab_repo" , 8+ "ssh://[email protected] /v3/Fabrikam/Project1/fab_repo" , 9+ "[email protected] :v3/Fabrikam/Project1/fab_repo" , 10+ ] ) ( "uses Azure's HTTPS host and repository path for %s" , ( url ) => {
11+ expect ( cloneUrlForProtocol ( url , "https" ) ) . toBe (
12+ "https://dev.azure.com/Fabrikam/Project1/_git/fab_repo" ,
13+ ) ;
14+ } ) ;
15+
16+ it . each ( [
17+ "https://dev.azure.com/Fabrikam/Project1/_git/fab_repo" ,
18+ "https://[email protected] /Fabrikam/Project1/_git/fab_repo" , 19+ "https://DEV.AZURE.COM/Fabrikam/Project1/_git/fab_repo" ,
20+ ] ) ( "uses Azure's SSH host and repository path for %s" , ( url ) => {
21+ expect ( cloneUrlForProtocol ( url , "ssh" ) ) . toBe (
22+ "[email protected] :v3/Fabrikam/Project1/fab_repo" , 23+ ) ;
24+ } ) ;
25+
26+ it ( "preserves encoded Azure repository components and same-protocol URLs" , ( ) => {
27+ const ssh = "[email protected] :v3/Fabrikam/Project%20One/fab%20repo" ; 28+ const https = "https://dev.azure.com/Fabrikam/Project%20One/_git/fab%20repo" ;
29+ expect ( cloneUrlForProtocol ( ssh , "https" ) ) . toBe ( https ) ;
30+ expect ( cloneUrlForProtocol ( https , "ssh" ) ) . toBe ( ssh ) ;
31+ expect ( cloneUrlForProtocol ( ssh , "ssh" ) ) . toBe ( ssh ) ;
32+ expect ( cloneUrlForProtocol ( https , "https" ) ) . toBe ( https ) ;
33+ } ) ;
34+
35+ it ( "refuses Azure rewrites when the project is missing or a custom port is set" , ( ) => {
36+ expect ( cloneUrlForProtocol ( "[email protected] :v3/Fabrikam/fab_repo" , "https" ) ) . toBeNull ( ) ; 37+ expect ( cloneUrlForProtocol ( "https://dev.azure.com/Fabrikam/_git/fab_repo" , "ssh" ) ) . toBeNull ( ) ;
38+ expect (
39+ cloneUrlForProtocol (
40+ "ssh://[email protected] :2222/v3/Fabrikam/Project1/fab_repo" , 41+ "https" ,
42+ ) ,
43+ ) . toBeNull ( ) ;
44+ expect (
45+ cloneUrlForProtocol ( "https://dev.azure.com:8443/Fabrikam/Project1/_git/fab_repo" , "ssh" ) ,
46+ ) . toBeNull ( ) ;
47+ } ) ;
48+
649 it ( "switches between scp-style SSH and HTTPS" , ( ) => {
750 expect ( cloneUrlForProtocol ( "[email protected] :pingdotgg/t3code.git" , "https" ) ) . toBe ( 851 "https://github.com/pingdotgg/t3code.git" ,
0 commit comments