diff --git a/dist/obfuscate.js b/dist/obfuscate.js
index a3bd7b6e..8328ea74 100644
--- a/dist/obfuscate.js
+++ b/dist/obfuscate.js
@@ -76,6 +76,8 @@ function (_Component) {
link = "sms:".concat(props.sms);
} else if (props.facetime) {
link = "facetime:".concat(props.facetime);
+ } else if (props.href) {
+ link = props.href;
} else if (_typeof(props.children) !== 'object') {
link = props.children;
} else {
@@ -124,13 +126,14 @@ function (_Component) {
sms = _this$props.sms,
facetime = _this$props.facetime,
email = _this$props.email,
+ href = _this$props.href,
headers = _this$props.headers,
obfuscate = _this$props.obfuscate,
linkText = _this$props.linkText,
style = _this$props.style,
- others = _objectWithoutProperties(_this$props, ["element", "children", "tel", "sms", "facetime", "email", "headers", "obfuscate", "linkText", "style"]);
+ others = _objectWithoutProperties(_this$props, ["element", "children", "tel", "sms", "facetime", "email", "href", "headers", "obfuscate", "linkText", "style"]);
- var propsList = children || tel || sms || facetime || email;
+ var propsList = children || tel || sms || facetime || email || href;
var obsStyle = _objectSpread({}, style || {}, {
unicodeBidi: 'bidi-override',
diff --git a/package-lock.json b/package-lock.json
index 39f8674a..abf9b05d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "react-obfuscate",
- "version": "3.3.1",
+ "version": "3.4.0-0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
diff --git a/package.json b/package.json
index 50dc0b52..83144030 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "react-obfuscate",
- "version": "3.3.1",
+ "version": "3.4.0-0",
"description": "An intelligent React component to obfuscate any contact link",
"main": "dist/obfuscate.js",
"files": [
diff --git a/pages/index.js b/pages/index.js
index 68087a1a..92726bfc 100644
--- a/pages/index.js
+++ b/pages/index.js
@@ -157,6 +157,9 @@ const headerCode = `
➡️ Facetime:
+
+ ➡️ Any other URL:
+ Chat On WhatsApp
➡️ Child Elements:
diff --git a/readme.md b/readme.md
index 71844fcd..0a536263 100644
--- a/readme.md
+++ b/readme.md
@@ -78,9 +78,10 @@ export default () => (
| tel | `string` | `` | `null` | telephone number of the intended recipient |
| sms | `string` | `` | `null` | sms number of the intended recipient |
| facetime | `string` | `` | `null` | facetime address of the intended recipient |
+| href | `string` | `` | `null` | Obfuscate any other URL type |
| headers | `object` | `` | `null` | subject, cc, bcc, body, etc |
| obfuscate | `boolean` | `` | `true` | set to false to disable obfuscation |
-| linkText | `string` | `` | `obfuscated` | add custom pre-interaction href attribute placeholder text |
+| linkText | `string` | `` | `obfuscated` | add custom pre-interaction href attribute placeholder text |
| element | `string` | `` | `'a'` | custom element to render instead of an `a` tag |
| onClick | `function` | `` | `null` | called prior to setting location (e.g. for analytics tracking) |
diff --git a/src/obfuscate.js b/src/obfuscate.js
index 3f04728e..2fb87c8f 100644
--- a/src/obfuscate.js
+++ b/src/obfuscate.js
@@ -32,6 +32,8 @@ export default class Obfuscate extends Component {
link = `sms:${props.sms}`
} else if (props.facetime) {
link = `facetime:${props.facetime}`
+ } else if (props.href) {
+ link = props.href
} else if (typeof props.children !== 'object') {
link = props.children
} else {
@@ -81,6 +83,7 @@ export default class Obfuscate extends Component {
sms,
facetime,
email,
+ href,
headers,
obfuscate,
linkText,
@@ -88,7 +91,7 @@ export default class Obfuscate extends Component {
...others
} = this.props
- const propsList = children || tel || sms || facetime || email
+ const propsList = children || tel || sms || facetime || email || href
const obsStyle = {
...(style || {}),
diff --git a/test/obfuscate.test.js b/test/obfuscate.test.js
index b406fb13..9f3eb279 100755
--- a/test/obfuscate.test.js
+++ b/test/obfuscate.test.js
@@ -15,7 +15,7 @@ describe('obfuscate', () => {
}
})
- test('renders an ofuscated href', () => {
+ test('renders an obfuscated href', () => {
const wrapper = shallow(
)
@@ -23,7 +23,7 @@ describe('obfuscate', () => {
expect(wrapper.prop('href')).toEqual('obfuscated')
})
- test('properly sets location.href when ofuscated email is clicked', () => {
+ test('properly sets location.href when obfuscated email is clicked', () => {
const wrapper = shallow(
)
@@ -32,7 +32,7 @@ describe('obfuscate', () => {
expect(global.window.location.href).toEqual(`mailto:${testEmail}`)
})
- test('properly sets location.href when ofuscated email with headers is clicked', () => {
+ test('properly sets location.href when obfuscated email with headers is clicked', () => {
const headers = {
cc: 'dade@zero-cool.af',
bcc: 'smith@machina.net',
@@ -49,7 +49,7 @@ describe('obfuscate', () => {
.join('&')}`)
})
- test('properly sets location.href when ofuscated tel is clicked', () => {
+ test('properly sets location.href when obfuscated tel is clicked', () => {
const wrapper = shallow(
)
@@ -58,7 +58,17 @@ describe('obfuscate', () => {
expect(global.window.location.href).toEqual(`tel:${testTel}`)
})
- test('properly sets location.href when ofuscated sms is clicked', () => {
+ test('properly sets location.href when obfuscated href is clicked', () => {
+ const wrapper = shallow(
+
+ )
+
+ wrapper.simulate('click', { preventDefault: () => {} })
+ expect(global.window.location.href).toEqual(testTel)
+ })
+
+
+ test('properly sets location.href when obfuscated sms is clicked', () => {
const wrapper = shallow(
)
@@ -67,7 +77,7 @@ describe('obfuscate', () => {
expect(global.window.location.href).toEqual(`sms:${testTel}`)
})
- test('properly sets location.href when ofuscated facetime is clicked', () => {
+ test('properly sets location.href when obfuscated facetime is clicked', () => {
const wrapper = shallow(
)
@@ -76,7 +86,7 @@ describe('obfuscate', () => {
expect(global.window.location.href).toEqual(`facetime:${testTel}`)
})
- test('properly sets location.href when ofuscated without type is clicked', () => {
+ test('properly sets location.href when obfuscated without type is clicked', () => {
const wrapper = shallow(
test
)
@@ -85,7 +95,7 @@ describe('obfuscate', () => {
expect(global.window.location.href).toEqual('test')
})
- test('renders an unofuscated href when obfuscate prop equals false', () => {
+ test('renders an unobfuscated href when obfuscate prop equals false', () => {
const wrapper = shallow(
)
@@ -94,7 +104,7 @@ describe('obfuscate', () => {
expect(wrapper.prop('href')).toEqual(`sms:${testTel}`)
})
- test('renders an unofuscated child element left to right when obfuscate prop equals false', () => {
+ test('renders an unobfuscated child element left to right when obfuscate prop equals false', () => {
const wrapper = shallow(
)
@@ -103,7 +113,7 @@ describe('obfuscate', () => {
expect(wrapper.prop('href')).toEqual(`facetime:${testTel}`)
})
- test('renders an unofuscated child element right to left when obfuscated', () => {
+ test('renders an unobfuscated child element right to left when obfuscated', () => {
const wrapper = shallow(
)