(query: NavQuery)
| 46 | // Coerce a vue-router-style query (values may be strings, numbers, arrays, |
| 47 | // null/undefined) into a URL search string. |
| 48 | export function buildSearchString(query: NavQuery): string { |
| 49 | const search = new URLSearchParams(); |
| 50 | for (const [key, value] of Object.entries(query)) { |
| 51 | if (value === undefined || value === null) continue; |
| 52 | if (Array.isArray(value)) { |
| 53 | for (const item of value) { |
| 54 | if (item !== undefined && item !== null) |
| 55 | search.append(key, String(item)); |
| 56 | } |
| 57 | } else { |
| 58 | search.set(key, String(value)); |
| 59 | } |
| 60 | } |
| 61 | return search.toString(); |
| 62 | } |
| 63 | |
| 64 | // Fill `:param` placeholders and append a query string. |
| 65 | export function resolvePath( |
no test coverage detected