mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-03 00:15:11 +03:00
Merge pull request #6316 from halfdan/5606-subdir
Make regex for subfolder deduplication more restrictive
This commit is contained in:
commit
c549914ae8
@ -145,6 +145,10 @@ ConfigManager.prototype.set = function (config) {
|
||||
|
||||
subdir = localPath === '/' ? '' : localPath;
|
||||
|
||||
if (!_.isEmpty(subdir)) {
|
||||
this._config.slugs.protected.push(subdir.split('/').pop());
|
||||
}
|
||||
|
||||
// Allow contentPath to be over-written by passed in config object
|
||||
// Otherwise default to default content path location
|
||||
contentPath = this._config.paths.contentPath || path.resolve(appRoot, 'content');
|
||||
|
@ -59,8 +59,8 @@ function urlJoin() {
|
||||
|
||||
// Deduplicate subdirectory
|
||||
if (subdir) {
|
||||
subdirRegex = new RegExp(subdir + '\/' + subdir);
|
||||
url = url.replace(subdirRegex, subdir);
|
||||
subdirRegex = new RegExp(subdir + '\/' + subdir + '\/');
|
||||
url = url.replace(subdirRegex, subdir + '/');
|
||||
}
|
||||
|
||||
return url;
|
||||
|
@ -113,6 +113,14 @@ describe('Config', function () {
|
||||
config.paths.should.have.property('subdir', '/my/blog');
|
||||
});
|
||||
|
||||
it('should add subdir to list of protected slugs', function () {
|
||||
configUtils.set({url: 'http://my-ghost-blog.com/blog'});
|
||||
config.slugs.protected.should.containEql('blog');
|
||||
|
||||
configUtils.set({url: 'http://my-ghost-blog.com/my/blog'});
|
||||
config.slugs.protected.should.containEql('blog');
|
||||
});
|
||||
|
||||
it('should allow specific properties to be user defined', function () {
|
||||
var contentPath = path.join(config.paths.appRoot, 'otherContent', '/'),
|
||||
configFile = 'configFileDanceParty.js';
|
||||
@ -269,6 +277,10 @@ describe('Config', function () {
|
||||
configUtils.set({url: 'http://my-ghost-blog.com/blog'});
|
||||
config.urlFor(testContext, testData).should.equal('/blog/short-and-sweet/');
|
||||
config.urlFor(testContext, testData, true).should.equal('http://my-ghost-blog.com/blog/short-and-sweet/');
|
||||
|
||||
testData.post.url = '/blog-one/';
|
||||
config.urlFor(testContext, testData).should.equal('/blog/blog-one/');
|
||||
config.urlFor(testContext, testData, true).should.equal('http://my-ghost-blog.com/blog/blog-one/');
|
||||
});
|
||||
|
||||
it('should return url for a tag when asked for', function () {
|
||||
|
Loading…
Reference in New Issue
Block a user