@cloudflare/util-routes 5.4.0 → 5.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/useMatchRoute.d.ts +12 -1
- package/es/useMatchRoute.js +10 -2
- package/lib/useMatchRoute.js +10 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/useMatchRoute.d.ts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import { ExtractParam, RouteParams, RoutePatternResult } from './route';
|
|
2
|
-
export
|
|
2
|
+
export interface PathPattern {
|
|
3
|
+
/**
|
|
4
|
+
* Should be `true` if the static portions of the `path` should be matched in
|
|
5
|
+
* the same case.
|
|
6
|
+
*/
|
|
7
|
+
caseSensitive?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Should be `true` if this pattern should match the entire URL pathname.
|
|
10
|
+
*/
|
|
11
|
+
end?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function useMatchRoute<T extends RoutePatternResult<any>>(route: T, useMatch: (str: string | PathPattern) => any, options?: PathPattern): PathMatch<RouteParams<ExtractParam<T>>> | null;
|
|
3
14
|
/**
|
|
4
15
|
* A PathMatch contains info about how a PathPattern matched on a URL pathname.
|
|
5
16
|
*/
|
package/es/useMatchRoute.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
|
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
|
|
7
|
+
export function useMatchRoute(route, useMatch, options) {
|
|
8
|
+
return useMatch(_objectSpread(_objectSpread({}, options), {}, {
|
|
9
|
+
path: route.pattern
|
|
10
|
+
}));
|
|
3
11
|
}
|
|
4
12
|
/**
|
|
5
13
|
* A PathMatch contains info about how a PathPattern matched on a URL pathname.
|
package/lib/useMatchRoute.js
CHANGED
|
@@ -5,8 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useMatchRoute = useMatchRoute;
|
|
7
7
|
|
|
8
|
-
function
|
|
9
|
-
|
|
8
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
|
+
|
|
10
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
|
+
|
|
12
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
|
|
14
|
+
function useMatchRoute(route, useMatch, options) {
|
|
15
|
+
return useMatch(_objectSpread(_objectSpread({}, options), {}, {
|
|
16
|
+
path: route.pattern
|
|
17
|
+
}));
|
|
10
18
|
}
|
|
11
19
|
/**
|
|
12
20
|
* A PathMatch contains info about how a PathPattern matched on a URL pathname.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/util-routes",
|
|
3
3
|
"description": "Wraps path-to-regexp with a convenient, type-safe tagged template function",
|
|
4
|
-
"version": "5.4.
|
|
4
|
+
"version": "5.4.1",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
7
7
|
"author": "Frontend Team <frontend@cloudflare.com>",
|