Skip to content

Commit 7f1c9b3

Browse files
committed
use regex for stripping quotes
1 parent 2fcba06 commit 7f1c9b3

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

lib/rules/no-unused-prop-types.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,7 @@ module.exports = {
263263
* @param {string} the identifier to strip
264264
*/
265265
function stripQuotes(string) {
266-
if (string[0] === '\'' || string[0] === '"' && string[0] === string[string.length - 1]) {
267-
return string.slice(1, string.length - 1);
268-
}
269-
return string;
266+
return string.replace(/^\'|\'$/g, '');
270267
}
271268

272269
/**

lib/rules/prop-types.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,7 @@ module.exports = {
333333
* @param {string} the identifier to strip
334334
*/
335335
function stripQuotes(string) {
336-
if (string[0] === '\'' || string[0] === '"' && string[0] === string[string.length - 1]) {
337-
return string.slice(1, string.length - 1);
338-
}
339-
return string;
336+
return string.replace(/^\'|\'$/g, '');
340337
}
341338

342339
/**

0 commit comments

Comments
 (0)