2017-04-01 21:07:01 +00:00
|
|
|
'use strict'
|
2016-08-30 02:19:47 +00:00
|
|
|
|
2017-04-01 21:07:01 +00:00
|
|
|
import _ from 'lodash'
|
2017-02-09 01:52:37 +00:00
|
|
|
|
2017-04-01 21:07:01 +00:00
|
|
|
module.exports = {
|
|
|
|
/**
|
|
|
|
* Convert raw path to safe path
|
|
|
|
* @param {string} rawPath Raw path
|
|
|
|
* @returns {string} Safe path
|
|
|
|
*/
|
|
|
|
makeSafePath: (rawPath) => {
|
|
|
|
let rawParts = _.split(_.trim(rawPath), '/')
|
|
|
|
rawParts = _.map(rawParts, (r) => {
|
|
|
|
return _.kebabCase(_.deburr(_.trim(r)))
|
|
|
|
})
|
2017-02-10 01:24:28 +00:00
|
|
|
|
2017-04-01 21:07:01 +00:00
|
|
|
return _.join(_.filter(rawParts, (r) => { return !_.isEmpty(r) }), '/')
|
|
|
|
}
|
|
|
|
}
|