mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 19:33:02 +03:00
Trim version number to major and minor numbers only in meta tag
closes #880 - as the version number is under control from package.json use regex to trim
This commit is contained in:
parent
ea13511cc4
commit
8e3ddcbdcc
@ -208,8 +208,11 @@ coreHelpers = function (ghost) {
|
||||
});
|
||||
|
||||
ghost.registerThemeHelper('ghost_head', function (options) {
|
||||
var head = [];
|
||||
head.push('<meta name="generator" content="Ghost ' + this.version + '" />');
|
||||
var head = [],
|
||||
majorMinor = /^(\d+\.)?(\d+)/,
|
||||
trimmedVersion = this.version.match(majorMinor)[0];
|
||||
|
||||
head.push('<meta name="generator" content="Ghost ' + trimmedVersion + '" />');
|
||||
head.push('<link rel="alternate" type="application/rss+xml" title="RSS" href="/rss/">');
|
||||
|
||||
return ghost.doFilter('ghost_head', head, function (head) {
|
||||
|
@ -189,10 +189,16 @@ describe('Core Helpers', function () {
|
||||
});
|
||||
|
||||
it('returns meta tag string', function () {
|
||||
var rendered = handlebars.helpers.ghost_head.call({version: "0.3"});
|
||||
var rendered = handlebars.helpers.ghost_head.call({version: "0.3.0"});
|
||||
should.exist(rendered);
|
||||
rendered.string.should.equal('<meta name="generator" content="Ghost 0.3" />\n<link rel="alternate" type="application/rss+xml" title="RSS" href="/rss/">');
|
||||
});
|
||||
|
||||
it('returns meta tag string even if version is invalid', function () {
|
||||
var rendered = handlebars.helpers.ghost_head.call({version: "0.9"});
|
||||
should.exist(rendered);
|
||||
rendered.string.should.equal('<meta name="generator" content="Ghost 0.9" />\n<link rel="alternate" type="application/rss+xml" title="RSS" href="/rss/">');
|
||||
});
|
||||
});
|
||||
|
||||
describe('ghost_foot Helper', function () {
|
||||
|
Loading…
Reference in New Issue
Block a user