remove blog URL before save it

This commit is contained in:
Jean-Christian Paul Denis 2023-04-30 23:14:47 +02:00
parent 7214890c44
commit ab388b136e
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951

View File

@ -107,8 +107,8 @@ class Alias
return;
}
$url = trim($url);
$destination = trim($destination);
$url = self::removeBlogUrl($url);
$destination = self::removeBlogUrl($destination);
if (empty($url)) {
throw new Exception(__('Alias URL is empty.'));
@ -159,4 +159,16 @@ class Alias
->where('blog_id = ' . $sql->quote((string) dcCore::app()->blog->id))
->delete();
}
/**
* Remove blog URL from alias URLs.
*
* @param string $url The URL to clean
*
* @return string The cleaned URL
*/
public static function removeBlogUrl(string $url): string
{
return str_replace(dcCore::app()->blog->url, '', trim($url));
}
}