@@ -14,17 +14,35 @@ export function preserveQueryInUrl(url: string, preserveQuery: PreserveQuery): s
1414}
1515
1616/**
17- * Internal helper to merge query parameters from 2 URL's into a third.
17+ * Helper that merges query parameters from 2 URL's together.
18+ *
19+ * ### Important Notes
20+ *
21+ * + To preserve system resources, `set1` is modified directly to contain the merged results.
22+ * + If the provided `set1` is `undefined` and all query parameters are to be preserved, then `set2` will be returned
23+ * directly.
24+ * + If `set1` is `undefined`, a new `URLSearchParams` will be created (and returned) to contain the merged results.
25+ * + The return value will be `undefined` whenever `set1` is `undefined` and `set2` is also `undefined` or empty.
1826 * @param set1: First set of query parameters.
1927 * @param set2: Second set of query parameters.
28+ * @returns The merged `URLSearchParams`, or `undefined`.
2029 */
2130export function mergeQueryParams ( set1 : URLSearchParams | undefined , set2 : URLSearchParams | undefined ) : URLSearchParams | undefined ;
2231/**
23- * Internal helper to merge query parameters for calculateHref.
24- * This handles the URLSearchParams merging logic without URL reconstruction.
25- * @param existingParams Existing URLSearchParams from the new URL.
32+ * Helper that merges the given search parameters with the ones found in the current environment's URL.
33+ *
34+ * ### Important Notes
35+ *
36+ * + To preserve system resources, `existingParams` is modified directly to contain the merged results.
37+ * + The `URLSearchParams` from the global `location` object will be returned when all query parameters are preserved
38+ * and `existingParams` is `undefined`.
39+ * + If `existingParams` is `undefined`, a new `URLSearchParams` will be created (and returned) to contain the merged
40+ * results.
41+ * + The return value will be `undefined` whenever `existingParams` is `undefined` and the global `location`'s search
42+ * parameters are empty.
43+ * @param existingParams Existing `URLSearchParams` from the new URL.
2644 * @param preserveQuery The query preservation options.
27- * @returns The merged URLSearchParams or undefined if no merging is needed .
45+ * @returns The merged ` URLSearchParams`, or ` undefined` .
2846 */
2947export function mergeQueryParams ( existingParams : URLSearchParams | undefined , preserveQuery ?: PreserveQuery ) : URLSearchParams | undefined ;
3048export function mergeQueryParams ( set1 : URLSearchParams | undefined , pqOrSet2 : PreserveQuery | URLSearchParams | undefined ) : URLSearchParams | undefined {
0 commit comments