(url: string)
| 299 | const wikiPDFPathRegexp = /^\/.*\/[a-z]+\:[^\:\/]+\.pdf/i; |
| 300 | |
| 301 | export function isPDF(url: string): boolean { |
| 302 | try { |
| 303 | const {hostname, pathname} = new URL(url); |
| 304 | if (pathname.includes('.pdf')) { |
| 305 | if ( |
| 306 | ((hostname.endsWith('.wikimedia.org') || hostname.endsWith('.wikipedia.org')) && pathname.match(wikiPDFPathRegexp)) || |
| 307 | (hostname.endsWith('.dropbox.com') && pathname.startsWith('/s/') && (pathname.endsWith('.pdf') || pathname.endsWith('.PDF'))) |
| 308 | ) { |
| 309 | return false; |
| 310 | } |
| 311 | if (pathname.endsWith('.pdf')) { |
| 312 | for (let i = pathname.length; i >= 0; i--) { |
| 313 | if (pathname[i] === '=') { |
| 314 | return false; |
| 315 | } else if (pathname[i] === '/') { |
| 316 | return true; |
| 317 | } |
| 318 | } |
| 319 | } else { |
| 320 | return false; |
| 321 | } |
| 322 | } |
| 323 | } catch (e) { |
| 324 | // Do nothing |
| 325 | } |
| 326 | return false; |
| 327 | } |
| 328 | |
| 329 | const indexedSiteLists = new WeakMap<string[], URLTemplateIndex>(); |
| 330 |
no outgoing calls
no test coverage detected