@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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 5.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 8c2729a131: Support `PathPattern` options in `useMatchRoute` for caseSensitive and end matching
8
+
3
9
  ## 5.4.0
4
10
 
5
11
  ### Minor Changes
@@ -1,5 +1,16 @@
1
1
  import { ExtractParam, RouteParams, RoutePatternResult } from './route';
2
- export declare function useMatchRoute<T extends RoutePatternResult<any>>(route: T, useMatch: (str: string) => any): PathMatch<RouteParams<ExtractParam<T>>> | null;
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
  */
@@ -1,5 +1,13 @@
1
- export function useMatchRoute(route, useMatch) {
2
- return useMatch(route.pattern);
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.
@@ -5,8 +5,16 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useMatchRoute = useMatchRoute;
7
7
 
8
- function useMatchRoute(route, useMatch) {
9
- return useMatch(route.pattern);
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.0",
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>",