({ sectionId, query, replace = false })
| 288 | } |
| 289 | |
| 290 | function 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 | |
| 310 | function getSectionDescription(section) { |
| 311 | if (!section) return ''; |
no test coverage detected