Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-653

Appending a context to an URL of the Index page results in too many slashes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 5.1.0.3
    • 5.1.0.4
    • tapestry-core
    • None

    Description

      When creating a page link to the Index page with a context, Tapestry creates a link with two slashes after the context path
      Example: /app//123

      Because LinkImpl uses RequestPathOptimizer.optimizePath() inside the methode toUri() the url is optimized to 123. So the link to the Index page will work.

      But when you write a test for a page Foo (which contains a link to Index page) with PageTester, the test will fail because RequestPathOptimizer does not cut the url. The optimizer skips the optimization because in tests you can not use SymbolConstants.FORCE_ABSOLUTE_URIS = false. PagesTestes throws an exception if a path does not start with context path.

      <t:pagelink page="Index" context="123">...</t:pagelink>

      To fix the problem we have to check inside ComponentEventLinkEncoderImpl.appendContext() if the url ends with a slash.

      public void appendContext(EventContext context, StringBuilder builder)
      {
      String encoded = contextPathEncoder.encodeIntoPath(context);

      if (encoded.length() > 0)
      {
      if(!encoded.endsWith(SLASH))

      { builder.append(SLASH); }

      builder.append(encoded);
      }
      }

      Attachments

        Activity

          People

            hlship Howard Lewis Ship
            igor.drobiazko Igor Drobiazko
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: