PageSourceSearch

https://natureetprogres.org/tools/bazar/presentation/javascripts/export.js

js natureetprogres.org collected 2026-09-24 20:09:06 UTC 1,224 bytes, 41 lines download raw bytes

1import { mergeSearchParams } from './url.js'
2
3export function updateExportLinks(pSearchParams) {
4  document.querySelectorAll('.export-links > a').forEach((pLink) => {
5    const vOldHREF = pLink.getAttribute('data-href')
6
7    if (!vOldHREF || vOldHREF.trim() === '') {
8      console.error('Invalid URL provided.')
9      return
10    }
11
12    try {
13      const vURL = new URL(vOldHREF)
14      const vAllowedProtocols = ['http:', 'https:']
15      if (!vAllowedProtocols.includes(vURL.protocol)) {
16        console.error('Blocked unsafe URL protocol:', vURL.protocol)
17        return
18      }
19
20      const vRawSearch = vURL.search.substring(1)
21      const vSegments = vRawSearch.split('&')
22      const vHandler = vSegments[0]
23      const vExistingParamsStr = vSegments.slice(1).join('&')
24      const vMergedParams = mergeSearchParams(
25        vExistingParamsStr,
26        pSearchParams,
27        { returnMode: 'string', overrideKeywords: false, overrideQuery: false },
28      )
29
30      let vNewSearch = `?${vHandler}`
31      if (vMergedParams) {
32        vNewSearch += `&${vMergedParams}`
33      }
34
35      vURL.search = vNewSearch
36      pLink.href = vURL.toString()
37    } catch (e) {
38      console.error('Error processing URL:', e)
39    }
40  })
41}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.