(state)
| 98 | } |
| 99 | |
| 100 | function updateQueryString(state) { |
| 101 | if (!hasLocation() || !hasHistory()) return; |
| 102 | |
| 103 | const params = new URLSearchParams(window.location.search); |
| 104 | PERSISTED_FIELDS.forEach((field) => params.delete(field)); |
| 105 | |
| 106 | Object.entries(state).forEach(([field, value]) => { |
| 107 | const formatted = formatForQuery(value); |
| 108 | if (formatted === undefined || formatted === '') return; |
| 109 | params.set(field, formatted); |
| 110 | }); |
| 111 | |
| 112 | const search = params.toString(); |
| 113 | const newUrl = `${window.location.pathname}${search ? `?${search}` : ''}${window.location.hash}`; |
| 114 | window.history.replaceState(null, '', newUrl); |
| 115 | } |
| 116 | |
| 117 | export function loadGeneratorState() { |
| 118 | return { |
no test coverage detected