mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05: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
1 changed files with 7 additions and 3 deletions
|
@ -55,9 +55,13 @@ export default Component.extend({
|
||||||
const urlParts = [];
|
const urlParts = [];
|
||||||
|
|
||||||
if (this.post.canonicalUrl) {
|
if (this.post.canonicalUrl) {
|
||||||
|
try {
|
||||||
const canonicalUrl = new URL(this.post.canonicalUrl);
|
const canonicalUrl = new URL(this.post.canonicalUrl);
|
||||||
urlParts.push(canonicalUrl.host);
|
urlParts.push(canonicalUrl.host);
|
||||||
urlParts.push(...canonicalUrl.pathname.split('/').reject(p => !p));
|
urlParts.push(...canonicalUrl.pathname.split('/').reject(p => !p));
|
||||||
|
} catch (e) {
|
||||||
|
// no-op, invalid URL
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const blogUrl = new URL(this.config.get('blogUrl'));
|
const blogUrl = new URL(this.config.get('blogUrl'));
|
||||||
urlParts.push(blogUrl.host);
|
urlParts.push(blogUrl.host);
|
||||||
|
|
Loading…
Add table
Reference in a new issue