replace-last
Advanced tools
Comparing version 1.0.1 to 1.0.2
'use strict'; | ||
const kindOf = require('kind-of'); | ||
const _ = require('lodash'); | ||
@@ -15,3 +16,3 @@ const replaceLast = function(str, pattern, replacement) { | ||
if (kindOf(pattern) === 'string') { | ||
pattern = new RegExp(pattern, 'g'); | ||
pattern = new RegExp(_.escapeRegExp(pattern), 'g'); | ||
} else if (kindOf(pattern) === 'regexp') { | ||
@@ -18,0 +19,0 @@ pattern = new RegExp(pattern.source, 'g'); |
{ | ||
"name": "replace-last", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Replaces last match for pattern in string with replacement", | ||
@@ -24,3 +24,4 @@ "author": "Daniel Lewis BSc (Hons)", | ||
"dependencies": { | ||
"kind-of": "^6.0.0" | ||
"kind-of": "^6.0.0", | ||
"lodash": "^4.17.4" | ||
}, | ||
@@ -27,0 +28,0 @@ "devDependencies": { |
@@ -28,2 +28,8 @@ 'use strict'; | ||
}); | ||
it('contains regex chars', function() { | ||
var replaceLast = require('../../index'); | ||
var result = replaceLast('hello . hello . hello', '.', 'bye'); | ||
imp.expect(result).to.equal('hello . hello bye hello'); | ||
}); | ||
}); | ||
@@ -59,2 +65,8 @@ | ||
}); | ||
it('contains regex chars', function() { | ||
var replaceLast = require('../../index'); | ||
var result = replaceLast('hello . hello . hello', /./, 'bye'); | ||
imp.expect(result).to.equal('hello . hello . hellbye'); | ||
}); | ||
}); | ||
@@ -61,0 +73,0 @@ |
* Browserify code | ||
* Node 4 windows failing | ||
* Usual tidy | ||
* escape regex string |
Sorry, the diff of this file is not supported yet
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
66731
141
2
+ Addedlodash@^4.17.4
+ Addedlodash@4.17.21(transitive)