Skip to content

Commit

Permalink
Allow child elements to pass without obfuscation
Browse files Browse the repository at this point in the history
  • Loading branch information
Coston Perkins committed Mar 23, 2019
1 parent 1df96bd commit 14430a5
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/obfuscate.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ export default class Obfuscate extends Component {
link = `sms:${props.sms}`
} else if (props.facetime) {
link = `facetime:${props.facetime}`
} else {
} else if (typeof props.children !== 'object') {
link = props.children
} else {
return '/'
}

return link
Expand All @@ -49,7 +51,7 @@ export default class Obfuscate extends Component {
if (onClick && typeof onClick === 'function') {
onClick()
}

window.location.href = this.createContactLink(this.props)
}

Expand All @@ -59,13 +61,15 @@ export default class Obfuscate extends Component {
})
}

reverse(s) {
return s
.split('')
.reverse()
.join('')
.replace('(', ')')
.replace(')', '(')
reverse(string) {
if (typeof string !== 'undefined') {
return string
.split('')
.reverse()
.join('')
.replace('(', ')')
.replace(')', '(')
}
}

render() {
Expand Down Expand Up @@ -94,7 +98,9 @@ export default class Obfuscate extends Component {
}

const link =
humanInteraction === true || obfuscate === false
humanInteraction === true ||
obfuscate === false ||
typeof children === 'object' // Allow child elements
? propsList
: this.reverse(propsList)

Expand Down

0 comments on commit 14430a5

Please sign in to comment.