netlify-cli 17.16.1 → 17.16.2

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.
@@ -1,5 +1,9 @@
1
1
  import type { RequestHandler } from 'express';
2
2
  import type { FunctionsRegistry } from './registry.js';
3
+ export declare const getFormHandler: ({ functionsRegistry, logWarning, }: {
4
+ functionsRegistry: FunctionsRegistry;
5
+ logWarning?: boolean | undefined;
6
+ }) => string | undefined;
3
7
  export declare const createFormSubmissionHandler: ({ functionsRegistry, siteUrl, }: {
4
8
  functionsRegistry: FunctionsRegistry;
5
9
  siteUrl: string;
@@ -1 +1 @@
1
- {"version":3,"file":"form-submissions-handler.d.ts","sourceRoot":"","sources":["../../../src/lib/functions/form-submissions-handler.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAS7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAqBtD,eAAO,MAAM,2BAA2B;uBAInB,iBAAiB;aAC3B,MAAM;MACb,cAwIH,CAAA"}
1
+ {"version":3,"file":"form-submissions-handler.d.ts","sourceRoot":"","sources":["../../../src/lib/functions/form-submissions-handler.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAU7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAEtD,eAAO,MAAM,cAAc;uBAIN,iBAAiB;;wBAqBrC,CAAA;AAED,eAAO,MAAM,2BAA2B;uBAInB,iBAAiB;aAC3B,MAAM;MACb,cAwIH,CAAA"}
@@ -7,18 +7,18 @@ import getRawBody from 'raw-body';
7
7
  import { warn } from '../../utils/command-helpers.js';
8
8
  import { BACKGROUND } from '../../utils/functions/index.js';
9
9
  import { capitalize } from '../string.js';
10
- // @ts-expect-error TS(7031) FIXME: Binding element 'functionsRegistry' implicitly has... Remove this comment to see the full error message
11
- const getFormHandler = function ({ functionsRegistry }) {
10
+ export const getFormHandler = function ({ functionsRegistry, logWarning = true, }) {
12
11
  const handlers = ['submission-created', `submission-created${BACKGROUND}`]
13
12
  .map((name) => functionsRegistry.get(name))
14
- .filter(Boolean)
13
+ .filter((func) => Boolean(func))
15
14
  .map(({ name }) => name);
16
15
  if (handlers.length === 0) {
17
- warn(`Missing form submission function handler`);
16
+ logWarning && warn(`Missing form submission function handler`);
18
17
  return;
19
18
  }
20
19
  if (handlers.length === 2) {
21
- warn(`Detected both '${handlers[0]}' and '${handlers[1]}' form submission functions handlers, using ${handlers[0]}`);
20
+ logWarning &&
21
+ warn(`Detected both '${handlers[0]}' and '${handlers[1]}' form submission functions handlers, using ${handlers[0]}`);
22
22
  }
23
23
  return handlers[0];
24
24
  };
@@ -130,7 +130,7 @@ export const createHandler = function (options) {
130
130
  'x-nf-site-id': [options?.siteInfo?.id ?? UNLINKED_SITE_MOCK_ID],
131
131
  [efHeaders.Geo]: Buffer.from(JSON.stringify(geoLocation)).toString('base64'),
132
132
  }).reduce((prev, [key, value]) => ({ ...prev, [key]: Array.isArray(value) ? value : [value] }), {});
133
- const rawQuery = new URLSearchParams(requestQuery).toString();
133
+ const rawQuery = new URL(request.originalUrl, 'http://example.com').search.slice(1);
134
134
  const protocol = options.config?.dev?.https ? 'https' : 'http';
135
135
  const url = new URL(requestPath, `${protocol}://${request.get('host') || 'localhost'}`);
136
136
  url.search = rawQuery;