-
Notifications
You must be signed in to change notification settings - Fork 212
Expand file tree
/
Copy pathrequest-processor.js
More file actions
35 lines (28 loc) · 1.05 KB
/
request-processor.js
File metadata and controls
35 lines (28 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
* Copyright (c) 2023, Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import {QueryParameters} from '@salesforce/pwa-kit-runtime/utils/ssr-request-processing'
const exclusions = ['removeme']
export const processRequest = ({path, querystring, parameters}) => {
console.assert(parameters, 'Missing parameters')
// Query string filtering
// Build a first QueryParameters object from the given querystring
const queryParameters = new QueryParameters(querystring)
// Build a second QueryParameters from the first, with all
// excluded parameters removed
const filtered = QueryParameters.from(
queryParameters.parameters.filter(
// parameter.key is always lower-case
(parameter) => !exclusions.includes(parameter.key)
)
)
// Re-generate the querystring
querystring = filtered.toString()
return {
path,
querystring
}
}