You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
431 B

  1. 'use strict'
  2. import _ from 'lodash'
  3. module.exports = {
  4. /**
  5. * Convert raw path to safe path
  6. * @param {string} rawPath Raw path
  7. * @returns {string} Safe path
  8. */
  9. makeSafePath: (rawPath) => {
  10. let rawParts = _.split(_.trim(rawPath), '/')
  11. rawParts = _.map(rawParts, (r) => {
  12. return _.kebabCase(_.deburr(_.trim(r)))
  13. })
  14. return _.join(_.filter(rawParts, (r) => { return !_.isEmpty(r) }), '/')
  15. }
  16. }