From 0c71d5596b343112bdfc26ab367fd7d368460679 Mon Sep 17 00:00:00 2001 From: Pravdomil Date: Tue, 13 Mar 2018 18:32:03 +0100 Subject: [PATCH 1/2] implement opt.camelCase --- lib/speakingurl.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/speakingurl.js b/lib/speakingurl.js index 4a62bc0..4643ce2 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,8 @@ } else { titleCase = !!opts.titleCase; } + + camelCase = !!opts.camelCase; // 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 +1604,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 +1624,7 @@ } } - if (!maintainCase && !titleCase) { + if (!maintainCase && !titleCase && !camelCase) { result = result.toLowerCase(); } @@ -1686,4 +1692,4 @@ } } catch (e) {} } -})(this); \ No newline at end of file +})(this); From 1b2718ada338849c04ac767237c913db2c32aab5 Mon Sep 17 00:00:00 2001 From: Pravdomil Date: Tue, 13 Mar 2018 18:33:34 +0100 Subject: [PATCH 2/2] fix --- lib/speakingurl.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/speakingurl.js b/lib/speakingurl.js index 4643ce2..985ff88 100644 --- a/lib/speakingurl.js +++ b/lib/speakingurl.js @@ -1500,6 +1500,10 @@ } 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)) {