Skip to content

Commit

Permalink
use local linkifyIt if adding handlers, to avoid polluting the global…
Browse files Browse the repository at this point in the history
… instance
  • Loading branch information
olslash committed May 27, 2016
1 parent 2cf3e99 commit 7e831e4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Linkify.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ class Linkify extends React.Component {
const { handlers } = this.props

if (handlers.length) {
this.linkify = new LinkifyIt();
this.linkify.tlds(tlds);

handlers.forEach(handler => {
linkify.add(handler.prefix, {
this.linkify.add(handler.prefix, {
validate: handler.validate,
normalize: handler.normalize
})
Expand All @@ -54,7 +57,9 @@ class Linkify extends React.Component {
parseCounter = 0

getMatches(string) {
return linkify.match(string);
const linkifyInstance = this.linkify ? this.linkify : linkify

return linkifyInstance.match(string);
}

parseString(string) {
Expand Down

0 comments on commit 7e831e4

Please sign in to comment.