this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at hotfix/infinite-loop-intersection-observer 48 lines 1.6 kB view raw
1import fs from 'fs'; 2import regexSupplant from 'twitter-text/dist/lib/regexSupplant.js'; 3import validDomain from 'twitter-text/dist/regexp/validDomain.js'; 4import validPortNumber from 'twitter-text/dist/regexp/validPortNumber.js'; 5import validUrlPath from 'twitter-text/dist/regexp/validUrlPath.js'; 6import validUrlPrecedingChars from 'twitter-text/dist/regexp/validUrlPrecedingChars.js'; 7import validUrlQueryChars from 'twitter-text/dist/regexp/validUrlQueryChars.js'; 8import validUrlQueryEndingChars from 'twitter-text/dist/regexp/validUrlQueryEndingChars.js'; 9 10// The difference with twitter-text's extractURL is that the protocol isn't 11// optional. 12 13const urlRegex = regexSupplant( 14 '(' + // $1 total match 15 '(#{validUrlPrecedingChars})' + // $2 Preceeding chracter 16 '(' + // $3 URL 17 '(https?:\\/\\/)' + // $4 Protocol (optional) <-- THIS IS THE DIFFERENCE, MISSING '?' AFTER PROTOCOL 18 '(#{validDomain})' + // $5 Domain(s) 19 '(?::(#{validPortNumber}))?' + // $6 Port number (optional) 20 '(\\/#{validUrlPath}*)?' + // $7 URL Path 21 '(\\?#{validUrlQueryChars}*#{validUrlQueryEndingChars})?' + // $8 Query String 22 ')' + 23 ')', 24 { 25 validUrlPrecedingChars, 26 validDomain, 27 validPortNumber, 28 validUrlPath, 29 validUrlQueryChars, 30 validUrlQueryEndingChars, 31 }, 32 'gi', 33); 34 35const filePath = 'src/data/url-regex.json'; 36fs.writeFile( 37 filePath, 38 JSON.stringify({ 39 source: urlRegex.source, 40 flags: urlRegex.flags, 41 }), 42 (err) => { 43 if (err) { 44 console.error(err); 45 } 46 console.log(`Wrote ${filePath}`); 47 }, 48);