remove blog URL before save it

master
Jean-Christian Paul Denis 2023-04-30 23:14:47 +02:00
parent 7214890c44
commit ab388b136e
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
1 changed files with 14 additions and 2 deletions

View File

@ -107,8 +107,8 @@ class Alias
return; return;
} }
$url = trim($url); $url = self::removeBlogUrl($url);
$destination = trim($destination); $destination = self::removeBlogUrl($destination);
if (empty($url)) { if (empty($url)) {
throw new Exception(__('Alias URL is empty.')); throw new Exception(__('Alias URL is empty.'));
@ -159,4 +159,16 @@ class Alias
->where('blog_id = ' . $sql->quote((string) dcCore::app()->blog->id)) ->where('blog_id = ' . $sql->quote((string) dcCore::app()->blog->id))
->delete(); ->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));
}
} }