Skip to content

Commit 40cdc5d

Browse files
committed
feat: Correct Typo in prefix parameter
BREAKING CHANGE: opts.preffix is now opts.prefix
1 parent 09cb301 commit 40cdc5d

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ If the string to match has accents, it will only match exact matches (case-insen
2525
import ultimateStringReplace from 'ultimate-string-replace';
2626
2727
const data = "Crème brûlée"
28-
const response = ultimateStringReplace(data, "rème brûlée", {'wrap_preffix': "<b>", 'wrap_suffix': "</b>" })
28+
const response = ultimateStringReplace(data, "rème brûlée", {'wrap_preffix': "<b>", 'wrap_sufix': "</b>" })
2929
// Result -> 'C<b>rème brûlée</b>';
3030
```
3131
## Examples of matches

test/ultimate-string-replace.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('string-replace', () => {
88
const response = ultimateStringReplace(data, 'he', {
99
wrap: true,
1010
wrap_preffix: '<b>',
11-
wrap_suffix: '</b>',
11+
wrap_sufix: '</b>',
1212
});
1313
expect(response).to.equal('<b>He</b>llo <b>he</b>llo');
1414
});
@@ -18,7 +18,7 @@ describe('string-replace', () => {
1818
const response = ultimateStringReplace(data, '23', {
1919
wrap: true,
2020
wrap_preffix: '<b>',
21-
wrap_suffix: '</b>',
21+
wrap_sufix: '</b>',
2222
});
2323
expect(response).to.equal('1<b>2 3</b>4');
2424
});
@@ -28,7 +28,7 @@ describe('string-replace', () => {
2828
const response = ultimateStringReplace(data, 'rème brûlée', {
2929
wrap: true,
3030
wrap_preffix: '<b>',
31-
wrap_suffix: '</b>',
31+
wrap_sufix: '</b>',
3232
});
3333
expect(response).to.equal('C<b>rème brûlée</b>');
3434
});
@@ -38,7 +38,7 @@ describe('string-replace', () => {
3838
const response = ultimateStringReplace(data, 'ví', {
3939
wrap: true,
4040
wrap_preffix: '<b>',
41-
wrap_suffix: '</b>',
41+
wrap_sufix: '</b>',
4242
});
4343
expect(response).to.equal('<b>Ví</b>ctor victor Victor');
4444
});
@@ -48,7 +48,7 @@ describe('string-replace', () => {
4848
const response = ultimateStringReplace(data, 'Ví', {
4949
wrap: true,
5050
wrap_preffix: '<b>',
51-
wrap_suffix: '</b>',
51+
wrap_sufix: '</b>',
5252
});
5353
expect(response).to.equal('<b>Ví</b>ctor victor Victor');
5454
});
@@ -58,7 +58,7 @@ describe('string-replace', () => {
5858
const response = ultimateStringReplace(data, 'no', {
5959
wrap: true,
6060
wrap_preffix: '<b>',
61-
wrap_suffix: '</b>',
61+
wrap_sufix: '</b>',
6262
});
6363
expect(response).to.equal(false);
6464
});

ultimate-string-replace.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const addSpacesAccents = str => {
1111
/**
1212
* @param {} string String with the original value
1313
* @param {} matcher string with the letters to replace
14-
* @param {} {opts} wrap_suffix and wrap_preffix, the suffix and preffix to append
14+
* @param {} {opts} wrap_sufix and wrap_prefix, the sufix and preffix to append
1515
*/
1616
export default function(string, matcher, opts) {
1717
if (!string || !matcher || !opts)
@@ -20,7 +20,7 @@ export default function(string, matcher, opts) {
2020
const re = addSpacesAccents(matcher);
2121
const normalizedString = string.normalize('NFD').replace(re, match => {
2222
coincidence = true;
23-
return `${opts.wrap_preffix}${match}${opts.wrap_suffix}`;
23+
return `${opts.wrap_preffix}${match}${opts.wrap_sufix}`;
2424
});
2525
return coincidence ? normalizedString : false;
2626
}

0 commit comments

Comments
 (0)