cb2521855378f51cc79a579faaa57a48ece6faed
max
  Wed Feb 1 03:18:46 2023 -0800
fixing hgc crash when protocol is not https, refs #30545

diff --git src/hg/lib/hCommon.c src/hg/lib/hCommon.c
index 644abe7..ee6c0a2 100644
--- src/hg/lib/hCommon.c
+++ src/hg/lib/hCommon.c
@@ -128,31 +128,31 @@
 // remove everything after ? in URL
 if (reqUrl) 
     {
     char *e = strchr(reqUrl, '?');
     if (e) *e = 0; 
     }
 else 
 {
     // when called from command line, cannot get argv so using dummy name
     reqUrl = "/cgi-bin/hgTracks";
     host = "genome.ucsc.edu";
     isHttps = "on";
 }
 
 char *prot = NULL;
-if (sameWord(isHttps, "on"))
+if (isHttps && sameWord(isHttps, "on"))
     prot = "https";
 else
     prot = "http";
 
 char *url = needMem(4000);
 safef(url, 4000, "%s://%s%s", prot, host, reqUrl);
 return url;
 }
 
 char *hgAbsUrlCgi(char *cgiName)
 /* Full absolute URL to another CGI, including the protocol part. Needs to be freed. Example argument: "hgTracks" */
 {
 char *url = hgAbsUrl();
 char *lastSlash = strrchr(url, '/');
 if (lastSlash!=NULL)