Skip to content

Commit

Permalink
Merged branch master into master
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaslabbe committed Oct 3, 2016
2 parents e590bcc + 891dab2 commit ab57b7f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/server/routes/post-upload.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import path from 'path'
import fse from 'fs-extra'
import mkdirp from 'mkdirp'
import limax from 'limax'

import {
config,
Hooks,
cleanSlug
Hooks
} from '../../cli'

var route = function(req, res, next){
Expand Down Expand Up @@ -52,7 +52,8 @@ var route = function(req, res, next){
var ext = filename.split('.')
ext = ext[ext.length - 1]
var randID = '-' + (((1+Math.random())*0x100000)|0).toString(16).substring(2)
var cleanFileName = cleanSlug(filename).replace(`.${config.files.templates.extension}`, `${randID}.${ext}`)

var cleanFileName = limax(filename, {separateNumbers: false}).replace(`.${ext}`, `${randID}.${ext}`)

filePath = path.join(folderFilePath, cleanFileName)
var createImage = function () {
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/string/urls.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"template name with à, é, û, UPPERCASE; @": "template-name-with-a-e-u-uppercase."
}
22 changes: 22 additions & 0 deletions test/url.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var chai = require('chai');

var cleanSlug = require('../src/cli').cleanSlug
var fse = require('fs-extra')
var config = require('../src/cli').config
config.set({root: __dirname + '/fixtures'})

describe('Url', function() {

var urls = fse.readJsonSync(__dirname + '/fixtures/string/urls.json', 'utf8')

/**
* getAbeImport
*
*/
it('configuration file', function() {
for(var key in urls){
chai.assert.equal(cleanSlug(key), urls[key] + config.files.templates.extension, key + 'slugified url did not match')
}
});

});

0 comments on commit ab57b7f

Please sign in to comment.