Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecated behavior: splat and capture named placeholders #1650

Closed
xsawyerx opened this issue Mar 12, 2022 · 1 comment
Closed

Deprecated behavior: splat and capture named placeholders #1650

xsawyerx opened this issue Mar 12, 2022 · 1 comment
Labels
Deprecated Features, code, etc. that are officially deprecated

Comments

@xsawyerx
Copy link
Member

Why?

The storage that contains parameters has two special keys: splat and capture. If you create a named placeholder using one of those names, it confuses the internal system, and the keywords splat and captures will assume there are captures or unnamed placeholder variables.

# Confuses the splat() keyword
get '/:name/:id/:splat' => sub {...};

# Confuses the captures() keyword
get '/:name/:id/:captures' => sub {...};

To avoid such confusion, we will simply not allow these named placeholders.

Benefits to Dancer2 codebase

While it was not the best decision to use the same top-level storage for both named placeholders, captures, and splats - leading to this issue - deprecating this allows us to be certain of the consistency of results in the core code and not have to worry about odd situations we need to debug in the future.

Benefit to Dancer2 Community

While this seems like a minor limitation (such a case was never reported), it might reduce the confusion when accidentally mixing named placeholders with keywords for non-named placeholders or regular expression captures.

Alternatives

Regular expressions still support named captures and have no limitations on Dancer2's side:

get qr{^ / (?<name> [^/]+) / (?<id> [^/]+) / (?<splat> [^/]+) $} => sub {...};

However, we still view "splat" and "captures" as confusing names to give your path matches since they are also keywords for path matches.

@xsawyerx xsawyerx added the Deprecated Features, code, etc. that are officially deprecated label Mar 12, 2022
@xsawyerx xsawyerx added this to the March 2023 Deprecations milestone Mar 12, 2022
@cromedome
Copy link
Contributor

Deprecated in #1696. Closing.

cromedome added a commit that referenced this issue Oct 9, 2023
    [ BUG FIXES ]
    * GH #1663: Allow overriding of prefix in add_route (GeekRuthie)
    * GH #1675: Stringify VERSION_FROM correctly in Makefile.PL (Jason
      A. Crome)
    * GH #1677: Don't deserialize multipart form data on post (Emil
      Perhinschi)
    * GH #1694: Update JS assets in Dancer2 app skel (Jason A. Crome)

    [ ENHANCEMENTS ]
    * PR #1682: Bump minimum version of Perl to 5.14 (Jason A. Crome)

    [ DOCUMENTATION ]
    * GH #1580: Document the purpose of the .dancer file (Jason A. Crome)
    * GH #1669: Show correct usage of Dancer2::Core::Error (GeekRuthie)
    * GH #1674: Fix POD for input_handle() (mauke)
    * GH #1414: Add documentation resources to the doc map (Jason A.
      Crome, Yanick Champoux)
    * PR #1684: Remove shumphrey from core developers (Steven Humphrey)
    * GH #1685: Document the versioning scheme and Dancer2 release
      process (Jason A. Crome)
    * PR #1688: Fixed various bugs/issues in Dancer2 Pod (Jason A. Crome)
    * PR #1691: Update the contribution guidelines (Jason A. Crome)
    * PR #1692: Change README extension .mkdn -> .md (Jason A. Crome)

    [ DEPRECATED ]
    * GH #1645: Deprecated Dancer2::Test (Jason A. Crome)
    * GH #1646: Deprecated keyword: push_header (Jason A. Crome)
    * GH #1647: Deprecated keyword: header (Jason A. Crome)
    * GH #1648: Deprecated keyword: headers (Jason A. Crome)
    * GH #1649: Deprecated keyword: context (Jason A. Crome)
    * GH #1650: Deprecated: splat/capture named placeholders (Jason A.
      Crome)
    * GH #1651: Deprecated core Request instance method:
      request->dispatch_path (Jason A. Crome)
    * GH #1652: Deprecated keyword in plugins: plugin_setting (Jason A.
      Crome)
    * GH #1653: Deprecated keyword in plugins: dancer_app (Jason A. Crome)
    * GH #1654: Deprecated keyword in plugins: request (Jason A. Crome)
    * GH #1655: Deprecated keyword in plugins: var (Jason A. Crome)
    * GH #1656: Deprecated keyword in plugins: hook (Jason A. Crome)

    [ MISC ]
    * GH #1659: Rename `master` branch to be `main` (Yanick Champoux)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecated Features, code, etc. that are officially deprecated
Projects
None yet
Development

No branches or pull requests

2 participants