Skip to content

Commit b5f6aed

Browse files
committed
chore(shared): Deprecate createPathMatcher
1 parent f9afa48 commit b5f6aed

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/shared': patch
3+
---
4+
5+
Deprecate `createPathMatcher()` and its pattern types (`PathMatcherParam`, `PathPattern`, `WithPathSegmentWildcard`). Pattern-based path matching is being phased out along with the framework-level `createRouteMatcher()` helpers and will be removed in the next major version. Use your framework's native routing primitives to decide which paths to protect instead.

packages/shared/src/pathMatcher.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,19 @@ type StripTrailingSlash<T extends string> = T extends '/'
1616
/**
1717
* Suggests the `:path*` subtree form (e.g. `/dashboard/:path*`), which matches on
1818
* path-segment boundaries. `/` is special-cased to `/:path*` to avoid a malformed `//:path*`.
19+
*
20+
* @deprecated Will be removed in the next major version together with {@link createPathMatcher}.
1921
*/
2022
export type WithPathSegmentWildcard<T = string> = T extends '/'
2123
? '/:path*'
2224
: `${StripTrailingSlash<T & string>}/:path*`;
25+
/**
26+
* @deprecated Will be removed in the next major version together with {@link createPathMatcher}.
27+
*/
2328
export type PathPattern = Autocomplete<WithPathSegmentWildcard>;
29+
/**
30+
* @deprecated Will be removed in the next major version together with {@link createPathMatcher}.
31+
*/
2432
export type PathMatcherParam = Array<RegExp | PathPattern> | RegExp | PathPattern;
2533

2634
export class MalformedURLError extends Error {
@@ -70,6 +78,10 @@ export const normalizePath = (pathname: string): string => {
7078
*
7179
* @param patterns - A string, RegExp, or array of patterns to match against
7280
* @returns A function that takes a pathname and returns true if it matches any of the patterns
81+
*
82+
* @deprecated This function will be removed in the next major version. Pattern-based path matching
83+
* can diverge from how frameworks route requests; use your framework's native routing primitives
84+
* to decide which paths to protect instead.
7385
*/
7486
export const createPathMatcher = (patterns: PathMatcherParam) => {
7587
const routePatterns = [patterns || ''].flat().filter(Boolean);

0 commit comments

Comments
 (0)