Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-4720

Hudson automatically adds forward-slash to end of sidebar link

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • core
    • None
    • Platform: All, OS: All

      Using the sidebar link plugin, I added links to EMMA coverage reports of the form:

      http://myserver:8081/job/MyJob/ws/emma/coverage/coverage.html

      But the link automatically gets a forward-slash appended to it, becoming:

      http://myserver:8081/job/MyJob/ws/emma/coverage/coverage.html/

      This causes all relative links on the coverage report to become invalid and
      return 404.

      E.g. a link to "_files/4.html" will be translated to

      http://myserver:8081/job/MyJob/ws/emma/coverage/coverage.html/_files/4.html

      when it should be

      http://myserver:8081/job/MyJob/ws/emma/coverage/_files/4.html

          [JENKINS-4720] Hudson automatically adds forward-slash to end of sidebar link

          Alan Harder added a comment -

          There is no code in sidebar-link doing that, but I see the behavior too.. Hudson
          must be adding the / so changing the category.

          Alan Harder added a comment - There is no code in sidebar-link doing that, but I see the behavior too.. Hudson must be adding the / so changing the category.

          Alan Harder added a comment -

          Confirmed.. Functions.getActionUrl() does this:

          if(urlName.startsWith("/"))
          return Stapler.getCurrentRequest().getContextPath()urlName'/';
          else
          // relative URL name
          return
          Stapler.getCurrentRequest().getContextPath()'/'+itUrl+urlName'/';

          so any relative URL (starting with / or not) gets a / on the end. I wonder if
          this behavior can be safely removed?

          Alan Harder added a comment - Confirmed.. Functions.getActionUrl() does this: if(urlName.startsWith("/")) return Stapler.getCurrentRequest().getContextPath() urlName '/'; else // relative URL name return Stapler.getCurrentRequest().getContextPath() '/'+itUrl+urlName '/'; so any relative URL (starting with / or not) gets a / on the end. I wonder if this behavior can be safely removed?

          cb372 added a comment -

          Thanks for the very fast response!

          I'm not familiar with the Hudson source, but at first glance it seems quite
          risky to alter that code just to fix this problem. Could have quite far-reaching
          side effects?

          cb372 added a comment - Thanks for the very fast response! I'm not familiar with the Hudson source, but at first glance it seems quite risky to alter that code just to fix this problem. Could have quite far-reaching side effects?

          Alan Harder added a comment -

          I checked the history, and that slash has been there nearly forever:

          Actionable.urlName added in r190
          Trailing / added in r347 to fix bug where current link is sometimes not bold
          Trailing / removed in r9642 (issues 1679,1335)
          Trailing / added back for non-absolute urls in r11319, fix to show current page
          in bold

          (yes, r347 out of over 23000).. but, it was removed for a while and the bug that
          reoccurred is just visual (not showing the current location in bold in the
          sidebar). So I'll investigate a bit and see if the slash can be removed and the
          emboldening code updated so we don't add that bug back a 3rd time.

          Alan Harder added a comment - I checked the history, and that slash has been there nearly forever: Actionable.urlName added in r190 Trailing / added in r347 to fix bug where current link is sometimes not bold Trailing / removed in r9642 (issues 1679,1335) Trailing / added back for non-absolute urls in r11319, fix to show current page in bold (yes, r347 out of over 23000).. but, it was removed for a while and the bug that reoccurred is just visual (not showing the current location in bold in the sidebar). So I'll investigate a bit and see if the slash can be removed and the emboldening code updated so we don't add that bug back a 3rd time.

          Code changed in hudson
          User: : mindless
          Path:
          trunk/hudson/main/core/src/main/java/hudson/Functions.java
          http://fisheye4.cenqua.com/changelog/hudson/?cs=23393
          Log:
          [FIXED JENKINS-4720] Don't always append / to non-absolute action URLs,
          as this may break some links (.../*.html for example).
          See related JENKINS-1335, JENKINS-1679, r347 and r11319.
          Updated hyperlinkMatchesCurrentPage to ignore trailing / in matching
          to avoid regression in bold context links.
          Also fixed tiny bug introduced in r13815 where "/" was changed to "."
          in moving code from jelly to Functions, causing a couple links in
          LogRecorder area (with href=".") to not show as bold.

          SCM/JIRA link daemon added a comment - Code changed in hudson User: : mindless Path: trunk/hudson/main/core/src/main/java/hudson/Functions.java http://fisheye4.cenqua.com/changelog/hudson/?cs=23393 Log: [FIXED JENKINS-4720] Don't always append / to non-absolute action URLs, as this may break some links (.../*.html for example). See related JENKINS-1335 , JENKINS-1679 , r347 and r11319. Updated hyperlinkMatchesCurrentPage to ignore trailing / in matching to avoid regression in bold context links. Also fixed tiny bug introduced in r13815 where "/" was changed to "." in moving code from jelly to Functions, causing a couple links in LogRecorder area (with href=".") to not show as bold.

          Code changed in hudson
          User: : mindless
          Path:
          trunk/www/changelog.html
          http://fisheye4.cenqua.com/changelog/hudson/?cs=23394
          Log:
          [FIXED JENKINS-4720] noting fix in r23393

          SCM/JIRA link daemon added a comment - Code changed in hudson User: : mindless Path: trunk/www/changelog.html http://fisheye4.cenqua.com/changelog/hudson/?cs=23394 Log: [FIXED JENKINS-4720] noting fix in r23393

            mindless Alan Harder
            cb372 cb372
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: