Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-string-replace-recursively

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-string-replace-recursively - npm Package Compare versions

Comparing version 0.1.22 to 0.1.23

2

package.json
{
"name": "react-string-replace-recursively",
"version": "0.1.22",
"version": "0.1.23",
"description": "replace strings that match a particular pattern with a React Component, recursively",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -32,5 +32,6 @@ # React String Replace Recursively

<ParentComponent>
["I appreciate a good",
["I appreciate a good ",
<Link to={"tags/#chairback"}>
[<span className='search-term-match'>chair</span>,
["#",
<span className='search-term-match'>chair</span>,
"back"]

@@ -37,0 +38,0 @@ </Link>,

@@ -15,2 +15,6 @@ const expect = require('chai').expect;

const _searchTermFn = function (rawText, processed) {
return {searchTerm: processed}
}
const config = {

@@ -26,6 +30,10 @@ 'url': {

matcherFn: _hashTagFn
},
'searchTerm': {
pattern: /(chair)/ig,
matcherFn: _searchTermFn
}
}
it('works in trivial case', function () {
it('works with trivial inputText', function () {
const inputText = ''

@@ -37,3 +45,3 @@ const result = patternReplacerCreator(config)(inputText)

it('works in simple case', function () {
it('works with one pattern', function () {
const inputText = "how #great this #is"

@@ -44,2 +52,15 @@ const result = patternReplacerCreator(config)(inputText)

})
it('recursively replaces a pattern that occurs within another', function () {
const inputText = "I appreciate a good #chairback I must say"
const result = patternReplacerCreator(config)(inputText)
const expected = ["I appreciate a good ",
{hashtag: ["#", {searchTerm: ["chair"]}, "back"]},
" I must say"]
expect(result).to.deep.equal(expected)
})
it('ignores a pattern that occurs within another when config indicates this should be done', function () {
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc