Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Allow multiple slugs in route segment #1000

Merged
merged 2 commits into from
May 4, 2020
Merged

Conversation

JohnPeel
Copy link
Contributor

@JohnPeel JohnPeel commented Nov 23, 2019

Allow multiple slugs in route segment

Description

Currently you are not allowed to have multiple slugs in a single segment. (e.g. src/routes/[file].[ext].js)

This merge request relates to issue #547.

The regex used to find these parts will detect file].[ext as a slug because it is greedy.
I've made it non-greedy..

I also fixed an issue with non-dynamic parts of the segment (e.g. the . in the above filename) that are being treated as regex.

Issues

  • The change to sanitize non-dynamic parts of the segment may break projects that take advantage of the bug.

Changes

  • Regex for getting parts from a file segement was made non-greedy.
  • Added regex sanitizing to non-dynamic parts of segment.
    • This broke a few tests (e.g. . => \.), these were fixed.
  • Added tests for multiple slugs (with and without nested square brackets).

Note

There is no lint script in your package.json.


Before submitting the PR, please make sure you do the following

  • It's really useful if your PR relates to an outstanding issue, so please reference it in your PR, or create an explanatory one for discussion. In many cases features are absent for a reason.
  • This message body should clearly illustrate what problems it solves. If there are related issues, remember to reference them.
  • Ideally, include a test that fails without this PR but passes with it. PRs will only be merged once they pass CI. (Remember to npm run lint!)

Tests

  • Run the tests tests with npm test or yarn test)

Regex for getting parts from a file segement was made non-greedy.
Added regex sanitizing to non-dynamic parts of segment.
Added a test for the new ability for multiple slugs.
@JohnPeel JohnPeel changed the title Allow multiple slugs in server route filename Allow multiple slugs in route segment Nov 23, 2019
@Conduitry Conduitry merged commit 8bcdfad into sveltejs:master May 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants