split-string
Advanced tools
Comparing version 3.1.0 to 4.0.0
26
index.js
@@ -28,5 +28,17 @@ /*! | ||
var opts = extend({sep: '.'}, options); | ||
var quotes = opts.quotes || ['"', "'", '`']; | ||
var quotes = opts.quotes || { | ||
'"': '"', | ||
"'": "'", | ||
'`': '`', | ||
'“': '”' | ||
}; | ||
if (Array.isArray(quotes)) { | ||
quotes = quotes.reduce(function(acc, ele) { | ||
acc[ele] = ele; | ||
return acc; | ||
}, {}); | ||
} | ||
var brackets; | ||
if (opts.brackets === true) { | ||
@@ -87,4 +99,4 @@ brackets = { | ||
if (quotes.indexOf(s) !== -1) { | ||
i = getClosingQuote(str, s, i + 1); | ||
if (quotes[s]) { | ||
i = getClosingQuote(str, quotes[s], i + 1); | ||
continue; | ||
@@ -120,4 +132,4 @@ } | ||
if (quotes.indexOf(ch) !== -1) { | ||
closeIdx = getClosingQuote(str, ch, idx + 1); | ||
if (quotes[ch]) { | ||
closeIdx = getClosingQuote(str, quotes[ch], idx + 1); | ||
if (closeIdx === -1) { | ||
@@ -164,3 +176,3 @@ arr[arr.length - 1] += ch; | ||
function keepQuotes(ch, opts) { | ||
if (opts.keepDoubleQuotes === true && ch === '"') return true; | ||
if (opts.keepDoubleQuotes === true && (ch === '"' || ch === '“' || ch === '”')) return true; | ||
if (opts.keepSingleQuotes === true && ch === "'") return true; | ||
@@ -167,0 +179,0 @@ return opts.keepQuotes; |
{ | ||
"name": "split-string", | ||
"description": "Split a string on a character except when the character is escaped.", | ||
"version": "3.1.0", | ||
"version": "4.0.0", | ||
"homepage": "https://github.com/jonschlinkert/split-string", | ||
@@ -6,0 +6,0 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", |
@@ -304,4 +304,4 @@ # split-string [![NPM version](https://img.shields.io/npm/v/split-string.svg?style=flat)](https://www.npmjs.com/package/split-string) [![NPM monthly downloads](https://img.shields.io/npm/dm/split-string.svg?style=flat)](https://npmjs.org/package/split-string) [![NPM total downloads](https://img.shields.io/npm/dt/split-string.svg?style=flat)](https://npmjs.org/package/split-string) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/split-string.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/split-string) | ||
| --- | --- | | ||
| 28 | [jonschlinkert](https://github.com/jonschlinkert) | | ||
| 9 | [doowb](https://github.com/doowb) | | ||
| 34 | [jonschlinkert](https://github.com/jonschlinkert) | | ||
| 10 | [doowb](https://github.com/doowb) | | ||
@@ -322,2 +322,2 @@ ### Author | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on November 19, 2017._ | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on November 22, 2017._ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14027
153