Fossil SCM

Fix the --baseurl option on "fossil server" so that it automatically strips of trailing / characters.

drh 2020-10-13 20:47 trunk
Commit 9e816f0aa91bc39ef3533b420f9b9ebf4b890acc269148401a9d06899091d7d1
1 file changed +4
+4
--- src/main.c
+++ src/main.c
@@ -1331,10 +1331,13 @@
13311331
13321332
if( g.zBaseURL!=0 ) return;
13331333
if( zAltBase ){
13341334
int i, n, c;
13351335
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;
13361339
if( strncmp(g.zTop, "http://", 7)==0 ){
13371340
/* it is HTTP, replace prefix with HTTPS. */
13381341
g.zHttpsURL = mprintf("https://%s", &g.zTop[7]);
13391342
}else if( strncmp(g.zTop, "https://", 8)==0 ){
13401343
/* it is already HTTPS, use it. */
@@ -1350,10 +1353,11 @@
13501353
g.zTop += i;
13511354
break;
13521355
}
13531356
}
13541357
}
1358
+ if( n==2 ) g.zTop = "";
13551359
if( g.zTop==g.zBaseURL ){
13561360
fossil_fatal("argument to --baseurl should be 'http://host/path'"
13571361
" or 'https://host/path'");
13581362
}
13591363
if( g.zTop[1]==0 ) g.zTop++;
13601364
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button