Escape forward slashes in regexes

This commit is contained in:
Adam Novak
2026-04-05 22:51:48 -04:00
parent 45658a7612
commit 45c9823c6f
+2 -2
View File
@@ -605,7 +605,7 @@ class _ChatScreenState extends State<ChatScreen> {
return match.group(1);
}
final directUrlMatch = RegExp(
r'^(?:https?://)?media\.giphy\.com/media/([A-Za-z0-9_-]+)/giphy\.gif$',
r'^(?:https?:\/\/)?media\.giphy\.com\/media\/([A-Za-z0-9_-]+)\/giphy\.gif$',
).firstMatch(trimmed);
if (directUrlMatch != null) {
return directUrlMatch.group(1);
@@ -615,7 +615,7 @@ class _ChatScreenState extends State<ChatScreen> {
// title, a dash, and the ID. IDs in this form *probably* can't
// contain dashes.
final pageMatch = RegExp(
r'^(?:https?://)?giphy\.com/gifs/(?:[^/?]*-)?([A-Za-z0-9_]+)/?$',
r'^(?:https?:\/\/)?giphy\.com\/gifs\/(?:[^/?]*-)?([A-Za-z0-9_]+)\/?$',
).firstMatch(trimmed);
return pageMatch?.group(1);
}