Closed fluks closed 4 years ago
It would be nice to be able to redirect Google AMP links to the regular page.
Here's an AMP URL:
https://www.google.com/amp/s/www.foxnews.com/us/kentucky-sheriff-suspends-law-enforcement-over-lack-of-funding-folks-lock-your-doors.amp
URL I want:
https://www.foxnews.com/us/kentucky-sheriff-suspends-law-enforcement-over-lack-of-funding-folks-lock-your-doors
Format could be %r[REGEX] and if more than one match is returned, i.e. capturing groups are used, replace the format with the second one.
Regex to get the wanted example URL:
wholeURL.match(/^(?:https:\/\/www.google.com\/amp\/s\/)(.*)(?:\.amp)$/) // or, note that groups starting with ?: are ignored %r[^(?:https:\/\/www.google.com\/amp\/s\/)(.*)(?:\.amp)$] // Returns: [ 'https://www.google.com/amp/s/www.foxnews.com/us/kentucky-sheriff-suspends-law-enforcement-over-lack-of-funding-folks-lock-your-doors.amp', // 'www.foxnews.com/us/kentucky-sheriff-suspends-law-enforcement-over-lack-of-funding-folks-lock-your-doors', // index: 0, // input: 'https://www.google.com/amp/s/www.foxnews.com/us/kentucky-sheriff-suspends-law-enforcement-over-lack-of-funding-folks-lock-your-doors.amp' ]
What about character sets (e.g. [a-z])? Escape them somehow?
Implemented in 4c4e327.
It would be nice to be able to redirect Google AMP links to the regular page.
Here's an AMP URL:
https://www.google.com/amp/s/www.foxnews.com/us/kentucky-sheriff-suspends-law-enforcement-over-lack-of-funding-folks-lock-your-doors.amp
URL I want:
https://www.foxnews.com/us/kentucky-sheriff-suspends-law-enforcement-over-lack-of-funding-folks-lock-your-doors
Format could be %r[REGEX] and if more than one match is returned, i.e. capturing groups are used, replace the format with the second one.
Regex to get the wanted example URL:
What about character sets (e.g. [a-z])? Escape them somehow?