MCPcopy Create free account
hub / github.com/jackvale/rectg / updateUrl

Function updateUrl

web/src/scripts/main.js:290–308  ·  view source on GitHub ↗
({ sectionId, query, replace = false })

Source from the content-addressed store, hash-verified

288}
289
290function updateUrl({ sectionId, query, replace = false }) {
291 const url = new URL(window.location);
292 if (query) {
293 url.pathname = '/';
294 url.searchParams.set('q', query);
295 url.searchParams.delete('c');
296 } else if (sectionId && sectionId !== 'featured') {
297 url.pathname = categoryPath(sectionId);
298 url.search = '';
299 url.hash = '';
300 } else {
301 url.pathname = '/';
302 url.searchParams.delete('c');
303 url.searchParams.delete('q');
304 }
305
306 const method = replace ? 'replaceState' : 'pushState';
307 window.history[method]({}, '', url);
308}
309
310function getSectionDescription(section) {
311 if (!section) return '';

Callers 2

renderSectionFunction · 0.85
renderSearchFunction · 0.85

Calls 1

categoryPathFunction · 0.70

Tested by

no test coverage detected