Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.1.6
    • Fix Version/s: 1.2-RC2
    • Labels:
      None

      Description

      Currently the redirectToActualUrl method concatenates the contextPath static prefix and the linkUrl. When I'm running the CDN resources plugin the linkUrl is an absolute url so I get something like this:

      http://myapp.com/static/http://myapp.com/static/style.min.css

      I was able to fix that by changing the method as follows from:

      def u = request.contextPath+staticUrlPrefix+res.linkUrl

      to:

      def u = !res.linkUrl?.contains( request.contextPath ) ? request.contextPath + staticUrlPrefix + res.linkUrl : res.linkUrl

      Does this fix make sense? If so should I issue a pull request?

      -Steve

        Activity

        Hide
        Marc Palmer added a comment -

        I'll need to investigate this. Note that the redirect mechanism is only for legacy resources the you are not linking to correctly, it shouldn't really be used - I would fix that first because it means your stuff will not cache/update properly

        The fix supplied will not be reliable because you can't just check for the context path being in a string. The context path can be blank for example, or a generic name like "user" which might occur elsewhere in a url

        Show
        Marc Palmer added a comment - I'll need to investigate this. Note that the redirect mechanism is only for legacy resources the you are not linking to correctly, it shouldn't really be used - I would fix that first because it means your stuff will not cache/update properly The fix supplied will not be reliable because you can't just check for the context path being in a string. The context path can be blank for example, or a generic name like "user" which might occur elsewhere in a url
        Hide
        Steve Holmes added a comment -

        Curious how you fixed it?

        Show
        Steve Holmes added a comment - Curious how you fixed it?
        Hide
        Marc Palmer added a comment -

        Sorry perhaps my comment wasn't clear. I haven't fixed anything, the issue is still open.

        I'm just saying that it would be best not to suffer redirects anyway, and link to the resources correctly if you can. Sounds like you have a link to a CSS that is not using r:resource/r:require/g:external (under grails 2) to link to it.

        Show
        Marc Palmer added a comment - Sorry perhaps my comment wasn't clear. I haven't fixed anything, the issue is still open. I'm just saying that it would be best not to suffer redirects anyway, and link to the resources correctly if you can. Sounds like you have a link to a CSS that is not using r:resource/r:require/g:external (under grails 2) to link to it.
        Hide
        Steve Holmes added a comment -

        I agree with you completely and I probably should have made myself a little more clear. We have a production application that builds static resource files as modules. We are also creating html content using the groovyPageRenderer that uses those resources.

        At one point we deployed the application and it was pointing to "/static/file.css". All of the static HTML content was created and everything was fine. The next time we built it it pointed to "/static/file.min.css". This caused all the previous HTML files to break because they were no longer pointing at the correct file and the redirect doesn't work. I was hoping to use the Redirect as a mitigation.

        By the way we never figured out why it changed from one deployment to another. We weren't able to recreate the scenario where it left off the .min. So instead we created the ability to recreate all static html files if need be. We have been using the minification plugin the entire time so it should have always created and used a minified version. In truth the mitigation wouldn't work anyways if it went from "file.min.css" to "file.css".

        Thanks for your help!

        Show
        Steve Holmes added a comment - I agree with you completely and I probably should have made myself a little more clear. We have a production application that builds static resource files as modules. We are also creating html content using the groovyPageRenderer that uses those resources. At one point we deployed the application and it was pointing to "/static/file.css". All of the static HTML content was created and everything was fine. The next time we built it it pointed to "/static/file.min.css". This caused all the previous HTML files to break because they were no longer pointing at the correct file and the redirect doesn't work. I was hoping to use the Redirect as a mitigation. By the way we never figured out why it changed from one deployment to another. We weren't able to recreate the scenario where it left off the .min. So instead we created the ability to recreate all static html files if need be. We have been using the minification plugin the entire time so it should have always created and used a minified version. In truth the mitigation wouldn't work anyways if it went from "file.min.css" to "file.css". Thanks for your help!
        Hide
        Marc Palmer added a comment -

        Seems like bad links were being generated. Shold never redirect to /static/<urlhere>

        Show
        Marc Palmer added a comment - Seems like bad links were being generated. Shold never redirect to /static/<urlhere>

          People

          • Assignee:
            Marc Palmer
            Reporter:
            Steve Holmes
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: