remove blog URL before save it
parent
7214890c44
commit
ab388b136e
|
@ -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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue