MCPcopy Create free account
hub / github.com/bestony/logoly / updateQueryString

Function updateQueryString

src/utils/persistentState.js:100–115  ·  view source on GitHub ↗
(state)

Source from the content-addressed store, hash-verified

98}
99
100function 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
117export function loadGeneratorState() {
118 return {

Callers 1

saveGeneratorStateFunction · 0.85

Calls 3

hasLocationFunction · 0.85
hasHistoryFunction · 0.85
formatForQueryFunction · 0.85

Tested by

no test coverage detected