From a76538cb342d15df671941c5e3f3e35a2b6e6e99 Mon Sep 17 00:00:00 2001 From: Krzysztof Kwiatkowski Date: Fri, 19 Oct 2018 13:42:06 +0200 Subject: [PATCH] empty separator passed in options object works as passed directly --- lib/speakingurl.js | 4 ++-- test/test-separator.js | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/speakingurl.js b/lib/speakingurl.js index 4a62bc0..08a7af2 100644 --- a/lib/speakingurl.js +++ b/lib/speakingurl.js @@ -1466,7 +1466,7 @@ uricNoSlashFlag = opts.uricNoSlash || false; markFlag = opts.mark || false; convertSymbols = (opts.symbols === false || opts.lang === false) ? false : true; - separator = opts.separator || separator; + separator = typeof opts.separator !== 'undefined' ? opts.separator : separator; if (uricFlag) { allowedChars += uricChars; @@ -1686,4 +1686,4 @@ } } catch (e) {} } -})(this); \ No newline at end of file +})(this); diff --git a/test/test-separator.js b/test/test-separator.js index 62d78b6..629ff65 100644 --- a/test/test-separator.js +++ b/test/test-separator.js @@ -170,6 +170,21 @@ describe('getSlug separator', function () { }); + it('should work the same regardless the method it was passed', function (done) { + // given + var testString = '-ä ß üö,.'; + var emptySeparator = ''; + + // when + var resultAsOption = getSlug(testString, { separator: emptySeparator }); + var resultDirect = getSlug(testString, emptySeparator); + + // then + resultAsOption.should.eql(resultDirect); + + done(); + }); + it('should return empty string because of non string input', function (done) { getSlug(true) @@ -178,4 +193,4 @@ describe('getSlug separator', function () { done(); }); -}); \ No newline at end of file +});