]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/helpers/regexp.ts
Remove exif tags when processing images
[github/Chocobozzz/PeerTube.git] / server / helpers / regexp.ts
1 // Thanks to https://regex101.com
2 function regexpCapture (str: string, regex: RegExp, maxIterations = 100) {
3 const result: RegExpExecArray[] = []
4 let m: RegExpExecArray
5 let i = 0
6
7 while ((m = regex.exec(str)) !== null && i < maxIterations) {
8 // This is necessary to avoid infinite loops with zero-width matches
9 if (m.index === regex.lastIndex) {
10 regex.lastIndex++
11 }
12
13 result.push(m)
14 i++
15 }
16
17 return result
18 }
19
20 export {
21 regexpCapture
22 }