Skip to content

Commit

Permalink
use regex for stripping quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
jseminck committed Aug 23, 2017
1 parent 2fcba06 commit 7f1c9b3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
5 changes: 1 addition & 4 deletions lib/rules/no-unused-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,7 @@ module.exports = {
* @param {string} the identifier to strip
*/
function stripQuotes(string) {
if (string[0] === '\'' || string[0] === '"' && string[0] === string[string.length - 1]) {
return string.slice(1, string.length - 1);
}
return string;
return string.replace(/^\'|\'$/g, '');
}

/**
Expand Down
5 changes: 1 addition & 4 deletions lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,7 @@ module.exports = {
* @param {string} the identifier to strip
*/
function stripQuotes(string) {
if (string[0] === '\'' || string[0] === '"' && string[0] === string[string.length - 1]) {
return string.slice(1, string.length - 1);
}
return string;
return string.replace(/^\'|\'$/g, '');
}

/**
Expand Down

0 comments on commit 7f1c9b3

Please sign in to comment.