Skip to content

[Suggestion] Hybrid Rollout - legacyRoutes doesn't support wildcard #20

Description

@bzhang-amb

We are migrating a client storefront from Sitegenesis to SF Next in mulitple phases.

In config.server.ts, we can define the legacyRoutes, and the README-HYBRID-PROXY.md says Supports exact paths and React Router-style parameterized routes:.

For phase 1, we need to redirect the categories URL to SG. I want to use wildcard * to capture all subcategories URLs like '/categoryLv1/*' so that I don't need to list all subcategories URLs in the config.server.ts.

But looking at legacy-routes.client.ts > routePatternToRegex(), this function actually doesn't support it. It will generate the wildcard exactly as single character *.

function routePatternToRegex(pattern: string): RegExp {
    const escaped = pattern.replace(/[.+*?^${}()|[\]\\]/g, '\\$&');

    const regexPattern = escaped.replace(/:([a-zA-Z_][a-zA-Z0-9_]*)/g, '([^/]+)');

    return new RegExp(`^${regexPattern}$`);
}

Can you please update it to support wildcard? Otherwise we need to add hundreds of exhausted URLs here instead of the top level category URL.

Thanks,
Biao

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions