diff --git a/lib/speakingurl.js b/lib/speakingurl.js index 4a62bc0..985ff88 100644 --- a/lib/speakingurl.js +++ b/lib/speakingurl.js @@ -1433,6 +1433,7 @@ var customReplacements = {}; var maintainCase; var titleCase; + var camelCase; var truncate; var uricFlag; var uricNoSlashFlag; @@ -1497,6 +1498,12 @@ } else { titleCase = !!opts.titleCase; } + + camelCase = !!opts.camelCase; + + if (!titleCase && camelCase) { + titleCase = true; + } // if custom config is an Array, rewrite to object format if (opts.custom && typeof opts.custom.length === 'number' && Array.prototype.toString.call(opts.custom)) { @@ -1601,6 +1608,9 @@ return (Object.keys(customReplacements).indexOf(j.toLowerCase()) < 0) ? j : j.toLowerCase(); }); } + if (camelCase && result.length) { + result = result[0].toLowerCase() + result.substr(1); + } // eliminate duplicate separators // add separator @@ -1618,7 +1628,7 @@ } } - if (!maintainCase && !titleCase) { + if (!maintainCase && !titleCase && !camelCase) { result = result.toLowerCase(); } @@ -1686,4 +1696,4 @@ } } catch (e) {} } -})(this); \ No newline at end of file +})(this);