f8ac1b1c8043509e4c4a3bdce70fbaa441ae24ac
angie
  Wed May 9 13:26:58 2018 -0700
webTimeStampedLinkToResource: add '../' to link not only when wrapInHtml is true, but also when returning just the link.  refs #21403

diff --git src/hg/lib/web.c src/hg/lib/web.c
index b182e6b..c34dc10 100644
--- src/hg/lib/web.c
+++ src/hg/lib/web.c
@@ -1253,43 +1253,44 @@
              dyStringContents(realFileName));
 
 // build and verify link path including timestamp in the form of dir/baseName + timeStamp or CGI Version + ext
 long mtime = fileModTime(dyStringContents(realFileName));
 struct dyString *linkWithTimestamp;
 
 linkWithTimestamp = dyStringCreate("%s/%s%s?v=%ld", dyStringContents(fullDirName), baseName, extension, mtime);
 
 // Free up all that extra memory
 dyStringFree(&realFileName);
 dyStringFree(&fullDirName);
 char *linkFull = dyStringCannibalize(&linkWithTimestamp);
 char *link = linkFull;
 if (docRoot != NULL)
     {
-    link = cloneString(linkFull + strlen(docRoot) + 1);
+    struct dyString *relativeLink = dyStringCreate("../%s", linkFull + strlen(docRoot) + 1);
+    link = dyStringCannibalize(&relativeLink);
     freeMem(linkFull);
     }
 
 if (wrapInHtml) // wrapped for christmas
     {
     struct dyString *wrapped = dyStringNew(0);
     if (js)
-        dyStringPrintf(wrapped,"<script type='text/javascript' SRC='../%s'></script>\n", link);
+        dyStringPrintf(wrapped,"<script type='text/javascript' SRC='%s'></script>\n", link);
     else if (style)
-        dyStringPrintf(wrapped,"<link rel='stylesheet' href='../%s' type='text/css'>\n", link);
+        dyStringPrintf(wrapped,"<link rel='stylesheet' href='%s' type='text/css'>\n", link);
     else // Will be image, since these are the only three choices allowed
-        dyStringPrintf(wrapped,"<IMG src='../%s' />\n", link);
+        dyStringPrintf(wrapped,"<IMG src='%s' />\n", link);
     freeMem(link);
     link = dyStringCannibalize(&wrapped);
     }
 
 return link;
 }
 
 char *webTimeStampedLinkToResourceOnFirstCall(char *fileName, boolean wrapInHtml)
 // If this is the first call, will return full path of timestamped link to the requested
 //   resource file (js, or css).  Free after use.
 // else returns NULL.  Useful to ensure multiple references to the same resource file are not made
 // NOTE: png, jpg and gif should also be supported but are untested.
 {
 if (!includedResourceFiles)
     includedResourceFiles = newHash(0);