0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Allow @ in image name for retina JS support (#7081)

no issue

- Updates unique filename generator to not replace `@` with `-`, but to leave it in place instead.
This commit is contained in:
Joris Berthelot 2016-07-15 18:50:41 +02:00 committed by Hannah Wolfe
parent 8c6ba47b0e
commit 795a59d677
2 changed files with 10 additions and 1 deletions

View file

@ -39,7 +39,7 @@ StorageBase.prototype.generateUnique = function (store, dir, name, ext, i) {
StorageBase.prototype.getUniqueFileName = function (store, image, targetDir) {
var ext = path.extname(image.name),
name = path.basename(image.name, ext).replace(/[\W]/gi, '-'),
name = path.basename(image.name, ext).replace(/[^\w@]/gi, '-'),
self = this;
return self.generateUnique(store, targetDir, name, ext, 0);

View file

@ -74,6 +74,15 @@ describe('Local File System Storage', function () {
}).catch(done);
});
it('should allow "@" symbol to image for Apple hi-res (retina) modifier', function (done) {
image.name = 'photo@2x.jpg';
localFileStore.save(image).then(function (url) {
url.should.equal('/content/images/2013/09/photo@2x.jpg');
done();
}).catch(done);
});
it('should send correct path to image when date is in Jan 2014', function (done) {
fakeDate(1, 2014);