mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-01 00:02:21 +09:00
Add unit tests for #429 and improve regexp efficiency
This commit is contained in:
parent
c6ed0bdd28
commit
45d17eb9bb
2 changed files with 11 additions and 3 deletions
|
|
@ -79,7 +79,7 @@ class MediaFilter
|
|||
*/
|
||||
public static function formatPrefix($prefix)
|
||||
{
|
||||
$prefix = preg_match('@^(https?:)?//(.*)$@i', $prefix, $matches) ? $matches[2] : $prefix;
|
||||
$prefix = preg_match('@^(?:https?:)?//(.*)$@i', $prefix, $matches) ? $matches[1] : $prefix;
|
||||
if (strpos($prefix, '/') === false)
|
||||
{
|
||||
$prefix .= '/';
|
||||
|
|
@ -117,7 +117,7 @@ class MediaFilter
|
|||
{
|
||||
$result[] = str_replace('\*\.', '[a-z0-9-]+\.', preg_quote($domain, '%'));
|
||||
}
|
||||
return '%^(https?:)?//(' . implode('|', $result) . ')%';
|
||||
return '%^(?:https?:)?//(' . implode('|', $result) . ')%';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -150,7 +150,7 @@ class MediaFilter
|
|||
{
|
||||
$result[] = str_replace('\*\.', '[a-z0-9-]+\.', preg_quote($domain, '%'));
|
||||
}
|
||||
return '%^(https?:)?//(' . implode('|', $result) . ')%';
|
||||
return '%^(?:https?:)?//(' . implode('|', $result) . ')%';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue