mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 13:54:35 +03:00
Fixed error when entering invalid URL in canonical URL field
closes https://github.com/TryGhost/Team/issues/745 - `URL()` will throw when given something it doesn't understand. As `seoURL` is just a display property it doesn't matter, we can catch the error and do nothing
This commit is contained in:
parent
8cbf2a5eea
commit
85f579b785
@ -55,9 +55,13 @@ export default Component.extend({
|
||||
const urlParts = [];
|
||||
|
||||
if (this.post.canonicalUrl) {
|
||||
const canonicalUrl = new URL(this.post.canonicalUrl);
|
||||
urlParts.push(canonicalUrl.host);
|
||||
urlParts.push(...canonicalUrl.pathname.split('/').reject(p => !p));
|
||||
try {
|
||||
const canonicalUrl = new URL(this.post.canonicalUrl);
|
||||
urlParts.push(canonicalUrl.host);
|
||||
urlParts.push(...canonicalUrl.pathname.split('/').reject(p => !p));
|
||||
} catch (e) {
|
||||
// no-op, invalid URL
|
||||
}
|
||||
} else {
|
||||
const blogUrl = new URL(this.config.get('blogUrl'));
|
||||
urlParts.push(blogUrl.host);
|
||||
|
Loading…
Reference in New Issue
Block a user