Ghost/core/server/helpers/url.js
JT Turner e4c52a6915 Fix urlFor to handle secure correctly
issue #6270
- Exposed getBaseUrl on the config class.
- Fix formatting config index as array was more then 140 characters long.
- Updated getBaseUrl to handle secure by replacing http with https if true.
- Fixed ghost_head helper to output canonical base url no https.
- Fixed ghost_head helper to set secure correctly for the rss link.
- Fixed navigation helper to pass secure in each nav item, so that urlFor can u$
- Fixed {{url}} to pass secure correctly to config.urlFor.
- Fixed test to use urlSSL over https besides for canonical.
- Add tests for {{url}} and to make sure they output https for absolute and secure.
- Update twitter and og url to use the canonical url.
2016-01-11 19:40:30 -08:00

34 lines
977 B
JavaScript

// # URL helper
// Usage: `{{url}}`, `{{url absolute="true"}}`
//
// Returns the URL for the current object scope i.e. If inside a post scope will return post permalink
// `absolute` flag outputs absolute URL, else URL is relative
var config = require('../config'),
schema = require('../data/schema').checks,
url;
url = function (options) {
var absolute = options && options.hash.absolute;
if (schema.isPost(this)) {
return config.urlFor('post', {post: this, secure: this.secure}, absolute);
}
if (schema.isTag(this)) {
return config.urlFor('tag', {tag: this, secure: this.secure}, absolute);
}
if (schema.isUser(this)) {
return config.urlFor('author', {author: this, secure: this.secure}, absolute);
}
if (schema.isNav(this)) {
return config.urlFor('nav', {nav: this, secure: this.secure}, absolute);
}
return config.urlFor(this, {}, absolute);
};
module.exports = url;