Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Commit

Permalink
fix(tools): string.contains should escape special characters
Browse files Browse the repository at this point in the history
Fixes #17
  • Loading branch information
elbywan committed Oct 9, 2017
1 parent 6ae798b commit efc23af
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build/angular/bundle/angular.umd.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/core/bundle/core.umd.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/react/bundle/react.umd.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/riot/bundle/riot.umd.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/tools/bundle/tools.umd.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/tools/bundle/tools.umd.min.js.map

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion build/tools/strings.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/tools/strings.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/vue/bundle/vue.umd.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/common/build/common.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/common/build/common.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/tools/strings.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// @flow

/* eslint-disable no-useless-escape */
export const string = (str: string) => ({
contains: (input: string) => !!str && !!str.match(new RegExp(`.*${ input }.*`, "gi"))
contains: (input: string) => !!str &&
!!str.match(new RegExp(`.*${ input.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&") }.*`, "gi"))
})

0 comments on commit efc23af

Please sign in to comment.