Fossil SCM
Fix the --baseurl option on "fossil server" so that it automatically strips of trailing / characters.
Commit
9e816f0aa91bc39ef3533b420f9b9ebf4b890acc269148401a9d06899091d7d1
Parent
d25027685b7d975…
1 file changed
+4
+4
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -1331,10 +1331,13 @@ | ||
| 1331 | 1331 | |
| 1332 | 1332 | if( g.zBaseURL!=0 ) return; |
| 1333 | 1333 | if( zAltBase ){ |
| 1334 | 1334 | int i, n, c; |
| 1335 | 1335 | g.zTop = g.zBaseURL = mprintf("%s", zAltBase); |
| 1336 | + i = (int)strlen(g.zBaseURL); | |
| 1337 | + while( i>3 && g.zBaseURL[i-1]=='/' ){ i--; } | |
| 1338 | + g.zBaseURL[i] = 0; | |
| 1336 | 1339 | if( strncmp(g.zTop, "http://", 7)==0 ){ |
| 1337 | 1340 | /* it is HTTP, replace prefix with HTTPS. */ |
| 1338 | 1341 | g.zHttpsURL = mprintf("https://%s", &g.zTop[7]); |
| 1339 | 1342 | }else if( strncmp(g.zTop, "https://", 8)==0 ){ |
| 1340 | 1343 | /* it is already HTTPS, use it. */ |
| @@ -1350,10 +1353,11 @@ | ||
| 1350 | 1353 | g.zTop += i; |
| 1351 | 1354 | break; |
| 1352 | 1355 | } |
| 1353 | 1356 | } |
| 1354 | 1357 | } |
| 1358 | + if( n==2 ) g.zTop = ""; | |
| 1355 | 1359 | if( g.zTop==g.zBaseURL ){ |
| 1356 | 1360 | fossil_fatal("argument to --baseurl should be 'http://host/path'" |
| 1357 | 1361 | " or 'https://host/path'"); |
| 1358 | 1362 | } |
| 1359 | 1363 | if( g.zTop[1]==0 ) g.zTop++; |
| 1360 | 1364 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -1331,10 +1331,13 @@ | |
| 1331 | |
| 1332 | if( g.zBaseURL!=0 ) return; |
| 1333 | if( zAltBase ){ |
| 1334 | int i, n, c; |
| 1335 | g.zTop = g.zBaseURL = mprintf("%s", zAltBase); |
| 1336 | if( strncmp(g.zTop, "http://", 7)==0 ){ |
| 1337 | /* it is HTTP, replace prefix with HTTPS. */ |
| 1338 | g.zHttpsURL = mprintf("https://%s", &g.zTop[7]); |
| 1339 | }else if( strncmp(g.zTop, "https://", 8)==0 ){ |
| 1340 | /* it is already HTTPS, use it. */ |
| @@ -1350,10 +1353,11 @@ | |
| 1350 | g.zTop += i; |
| 1351 | break; |
| 1352 | } |
| 1353 | } |
| 1354 | } |
| 1355 | if( g.zTop==g.zBaseURL ){ |
| 1356 | fossil_fatal("argument to --baseurl should be 'http://host/path'" |
| 1357 | " or 'https://host/path'"); |
| 1358 | } |
| 1359 | if( g.zTop[1]==0 ) g.zTop++; |
| 1360 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -1331,10 +1331,13 @@ | |
| 1331 | |
| 1332 | if( g.zBaseURL!=0 ) return; |
| 1333 | if( zAltBase ){ |
| 1334 | int i, n, c; |
| 1335 | g.zTop = g.zBaseURL = mprintf("%s", zAltBase); |
| 1336 | i = (int)strlen(g.zBaseURL); |
| 1337 | while( i>3 && g.zBaseURL[i-1]=='/' ){ i--; } |
| 1338 | g.zBaseURL[i] = 0; |
| 1339 | if( strncmp(g.zTop, "http://", 7)==0 ){ |
| 1340 | /* it is HTTP, replace prefix with HTTPS. */ |
| 1341 | g.zHttpsURL = mprintf("https://%s", &g.zTop[7]); |
| 1342 | }else if( strncmp(g.zTop, "https://", 8)==0 ){ |
| 1343 | /* it is already HTTPS, use it. */ |
| @@ -1350,10 +1353,11 @@ | |
| 1353 | g.zTop += i; |
| 1354 | break; |
| 1355 | } |
| 1356 | } |
| 1357 | } |
| 1358 | if( n==2 ) g.zTop = ""; |
| 1359 | if( g.zTop==g.zBaseURL ){ |
| 1360 | fossil_fatal("argument to --baseurl should be 'http://host/path'" |
| 1361 | " or 'https://host/path'"); |
| 1362 | } |
| 1363 | if( g.zTop[1]==0 ) g.zTop++; |
| 1364 |