@sasjs/api 0.17.4 → 0.17.5

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/build/browser.js CHANGED
@@ -1,4 +1,4 @@
1
- /* @sasjs/api 0.17.4 - the SASjs Server API, for a service worker. https://github.com/sasjs/api */
1
+ /* @sasjs/api 0.17.5 - the SASjs Server API, for a service worker. https://github.com/sasjs/api */
2
2
  "use strict";
3
3
  var SASjsApi = (() => {
4
4
  var __defProp = Object.defineProperty;
@@ -2839,17 +2839,17 @@ var SASjsApi = (() => {
2839
2839
  }
2840
2840
  return escape(segment);
2841
2841
  }).join("/");
2842
- return { route, keys, regex: new RegExp("^" + pattern + "/?$") };
2842
+ return { route, keys, regex: new RegExp("^" + pattern + "/?$", "i") };
2843
2843
  }
2844
2844
  );
2845
2845
  var exact = /* @__PURE__ */ new Map();
2846
2846
  for (const route of ROUTES)
2847
2847
  if (!route.path.includes("{"))
2848
- exact.set(route.method + " " + route.path, route);
2848
+ exact.set(route.method + " " + route.path.toLowerCase(), route);
2849
2849
  var findRoute = (method, path) => {
2850
2850
  const verb = method.toUpperCase();
2851
2851
  const clean = path.split("?")[0].replace(/\/+$/, "") || "/";
2852
- const hit = exact.get(verb + " " + clean);
2852
+ const hit = exact.get(verb + " " + clean.toLowerCase());
2853
2853
  if (hit) return { route: hit, params: {} };
2854
2854
  for (const candidate of compiled) {
2855
2855
  if (candidate.route.method !== verb) continue;
@@ -69,6 +69,17 @@ const escape = (segment) => segment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
69
69
  * Compiles a documented path into a matcher. The table is static, so this runs
70
70
  * once at import; `findRoute` then tests exact paths first (most of the API is
71
71
  * static) and only falls through to the templates for `{uid}`-style paths.
72
+ *
73
+ * Both matchers ignore case in the path's static segments, because the host
74
+ * does: express's `case sensitive routing` is off unless a server turns it on,
75
+ * and `sasjs/server` does not, so `/SASjsApi/drive/fileTree` reaches the
76
+ * handler documented as `filetree`. A matcher that compared the strings would
77
+ * answer 404 for a request the server serves - and did: the server's own front
78
+ * end calls the route with a capital T.
79
+ *
80
+ * The `i` flag applies to the static segments and to the parameter pattern; a
81
+ * captured value keeps the case it was sent with, which is what a host needs to
82
+ * look a user or a file up.
72
83
  */
73
84
  const compiled = exports.ROUTES.filter((route) => route.path.includes('{')).map((route) => {
74
85
  const keys = [];
@@ -82,12 +93,12 @@ const compiled = exports.ROUTES.filter((route) => route.path.includes('{')).map(
82
93
  return escape(segment);
83
94
  })
84
95
  .join('/');
85
- return { route, keys, regex: new RegExp('^' + pattern + '/?$') };
96
+ return { route, keys, regex: new RegExp('^' + pattern + '/?$', 'i') };
86
97
  });
87
98
  const exact = new Map();
88
99
  for (const route of exports.ROUTES)
89
100
  if (!route.path.includes('{'))
90
- exact.set(route.method + ' ' + route.path, route);
101
+ exact.set(route.method + ' ' + route.path.toLowerCase(), route);
91
102
  /**
92
103
  * The route a request names, or undefined when the API has no such operation.
93
104
  *
@@ -98,7 +109,7 @@ for (const route of exports.ROUTES)
98
109
  const findRoute = (method, path) => {
99
110
  const verb = method.toUpperCase();
100
111
  const clean = path.split('?')[0].replace(/\/+$/, '') || '/';
101
- const hit = exact.get(verb + ' ' + clean);
112
+ const hit = exact.get(verb + ' ' + clean.toLowerCase());
102
113
  if (hit)
103
114
  return { route: hit, params: {} };
104
115
  for (const candidate of compiled) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/routes/index.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,KAAK,EAAiB,MAAM,aAAa,CAAA;AA4DvD,eAAO,MAAM,MAAM,EAAE,KAAK,EAAgC,CAAA;AAW1D,4EAA4E;AAC5E,eAAO,MAAM,SAAS,GAAI,IAAI,MAAM,KAAG,KAAK,GAAG,SAAyB,CAAA;AAExE,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,KAAK,CAAA;IACZ,wDAAwD;IACxD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC/B;AAgCD;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GACpB,QAAQ,MAAM,EACd,MAAM,MAAM,KACX,UAAU,GAAG,SAuBf,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/routes/index.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,KAAK,EAAiB,MAAM,aAAa,CAAA;AA4DvD,eAAO,MAAM,MAAM,EAAE,KAAK,EAAgC,CAAA;AAW1D,4EAA4E;AAC5E,eAAO,MAAM,SAAS,GAAI,IAAI,MAAM,KAAG,KAAK,GAAG,SAAyB,CAAA;AAExE,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,KAAK,CAAA;IACZ,wDAAwD;IACxD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC/B;AA2CD;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GACpB,QAAQ,MAAM,EACd,MAAM,MAAM,KACX,UAAU,GAAG,SAuBf,CAAA"}
@@ -65,6 +65,17 @@ const escape = (segment) => segment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
65
65
  * Compiles a documented path into a matcher. The table is static, so this runs
66
66
  * once at import; `findRoute` then tests exact paths first (most of the API is
67
67
  * static) and only falls through to the templates for `{uid}`-style paths.
68
+ *
69
+ * Both matchers ignore case in the path's static segments, because the host
70
+ * does: express's `case sensitive routing` is off unless a server turns it on,
71
+ * and `sasjs/server` does not, so `/SASjsApi/drive/fileTree` reaches the
72
+ * handler documented as `filetree`. A matcher that compared the strings would
73
+ * answer 404 for a request the server serves - and did: the server's own front
74
+ * end calls the route with a capital T.
75
+ *
76
+ * The `i` flag applies to the static segments and to the parameter pattern; a
77
+ * captured value keeps the case it was sent with, which is what a host needs to
78
+ * look a user or a file up.
68
79
  */
69
80
  const compiled = ROUTES.filter((route) => route.path.includes('{')).map((route) => {
70
81
  const keys = [];
@@ -78,12 +89,12 @@ const compiled = ROUTES.filter((route) => route.path.includes('{')).map((route)
78
89
  return escape(segment);
79
90
  })
80
91
  .join('/');
81
- return { route, keys, regex: new RegExp('^' + pattern + '/?$') };
92
+ return { route, keys, regex: new RegExp('^' + pattern + '/?$', 'i') };
82
93
  });
83
94
  const exact = new Map();
84
95
  for (const route of ROUTES)
85
96
  if (!route.path.includes('{'))
86
- exact.set(route.method + ' ' + route.path, route);
97
+ exact.set(route.method + ' ' + route.path.toLowerCase(), route);
87
98
  /**
88
99
  * The route a request names, or undefined when the API has no such operation.
89
100
  *
@@ -94,7 +105,7 @@ for (const route of ROUTES)
94
105
  export const findRoute = (method, path) => {
95
106
  const verb = method.toUpperCase();
96
107
  const clean = path.split('?')[0].replace(/\/+$/, '') || '/';
97
- const hit = exact.get(verb + ' ' + clean);
108
+ const hit = exact.get(verb + ' ' + clean.toLowerCase());
98
109
  if (hit)
99
110
  return { route: hit, params: {} };
100
111
  for (const candidate of compiled) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sasjs/api",
3
- "version": "0.17.4",
3
+ "version": "0.17.5",
4
4
  "description": "The SASjs Server API, described once - a generated route table, the services behind it, and the conformance corpus both hosts run",
5
5
  "license": "MIT",
6
6
  "author": "SASjs",