Skip to content

Commit 7a157c1

Browse files
committed
Remove regexp when checking sources for <audio> and <video>
1 parent bff3251 commit 7a157c1

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

lib/src/replaced_element.dart

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -409,11 +409,7 @@ ReplacedElement parseReplacedElement(
409409
if (element.attributes['src'] != null) element.attributes['src'],
410410
...ReplacedElement.parseMediaSources(element.children),
411411
];
412-
bool matchFound = false;
413-
for (String s in sources) {
414-
matchFound = s == null ? false : RegExp(r"^((((H|h)(T|t)|(F|f))(T|t)(P|p)((S|s)?))\://)?(www.|[a-zA-Z0-9].)[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,6}(\:[0-9]{1,5})*(/($|[a-zA-Z0-9\.\,\;\?\'\\\+&amp;%\$#\=~_\-]+))*$").hasMatch(s);
415-
}
416-
if (sources == null || sources.isEmpty || !matchFound) {
412+
if (sources == null || sources.isEmpty || sources.first == null) {
417413
return EmptyContentElement();
418414
}
419415
return AudioContentElement(
@@ -450,11 +446,7 @@ ReplacedElement parseReplacedElement(
450446
if (element.attributes['src'] != null) element.attributes['src'],
451447
...ReplacedElement.parseMediaSources(element.children),
452448
];
453-
bool matchFound = false;
454-
for (String s in sources) {
455-
matchFound = s == null ? false : RegExp(r"^((((H|h)(T|t)|(F|f))(T|t)(P|p)((S|s)?))\://)?(www.|[a-zA-Z0-9].)[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,6}(\:[0-9]{1,5})*(/($|[a-zA-Z0-9\.\,\;\?\'\\\+&amp;%\$#\=~_\-]+))*$").hasMatch(s);
456-
}
457-
if (sources == null || sources.isEmpty || !matchFound) {
449+
if (sources == null || sources.isEmpty || sources.first == null) {
458450
return EmptyContentElement();
459451
}
460452
return VideoContentElement(

0 commit comments

Comments
 (0)