mirror of
https://github.com/Snigdha-OS/documentation.git
synced 2025-09-10 19:54:57 +02:00
20 lines
390 B
JavaScript
20 lines
390 B
JavaScript
/**
|
|
* Turn a list of extnames (*with* dots) into an expression.
|
|
*
|
|
* @param {ReadonlyArray<string>} extnames
|
|
* List of extnames.
|
|
* @returns {RegExp}
|
|
* Regex matching them.
|
|
*/
|
|
export function extnamesToRegex(extnames) {
|
|
return new RegExp(
|
|
'\\.(' +
|
|
extnames
|
|
.map(function (d) {
|
|
return d.slice(1)
|
|
})
|
|
.join('|') +
|
|
')([?#]|$)'
|
|
)
|
|
}
|