@wordpress/url
Advanced tools
Comparing version 4.7.0 to 4.7.1-next.5368f64a9.0
export { isURL } from './is-url'; | ||
export { isEmail } from './is-email'; | ||
export { isPhoneNumber } from './is-phone-number'; | ||
export { getProtocol } from './get-protocol'; | ||
@@ -4,0 +5,0 @@ export { isValidProtocol } from './is-valid-protocol'; |
export { isURL } from "./is-url"; | ||
export { isEmail } from "./is-email"; | ||
export { isPhoneNumber } from "./is-phone-number"; | ||
export { getProtocol } from "./get-protocol"; | ||
@@ -4,0 +5,0 @@ export { isValidProtocol } from "./is-valid-protocol"; |
@@ -96,2 +96,8 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "isPhoneNumber", { | ||
enumerable: true, | ||
get: function () { | ||
return _isPhoneNumber.isPhoneNumber; | ||
} | ||
}); | ||
Object.defineProperty(exports, "isURL", { | ||
@@ -171,2 +177,3 @@ enumerable: true, | ||
var _isEmail = require("./is-email"); | ||
var _isPhoneNumber = require("./is-phone-number"); | ||
var _getProtocol = require("./get-protocol"); | ||
@@ -173,0 +180,0 @@ var _isValidProtocol = require("./is-valid-protocol"); |
{ | ||
"name": "@wordpress/url", | ||
"version": "4.7.0", | ||
"version": "4.7.1-next.5368f64a9.0", | ||
"description": "WordPress URL utilities.", | ||
@@ -37,3 +37,3 @@ "author": "The WordPress Contributors", | ||
}, | ||
"gitHead": "c90d920de07c53dff82c5914635b56fafa503b7f" | ||
"gitHead": "24934a1f5251bbee15045d1fd953d9c5650317cd" | ||
} |
@@ -325,2 +325,20 @@ # URL | ||
### isPhoneNumber | ||
Determines whether the given string looks like a phone number. | ||
_Usage_ | ||
```js | ||
const isPhoneNumber = isPhoneNumber( '+1 (555) 123-4567' ); // true | ||
``` | ||
_Parameters_ | ||
- _phoneNumber_ `string`: The string to scrutinize. | ||
_Returns_ | ||
- `boolean`: Whether or not it looks like a phone number. | ||
### isURL | ||
@@ -327,0 +345,0 @@ |
export { isURL } from './is-url'; | ||
export { isEmail } from './is-email'; | ||
export { isPhoneNumber } from './is-phone-number'; | ||
export { getProtocol } from './get-protocol'; | ||
@@ -4,0 +5,0 @@ export { isValidProtocol } from './is-valid-protocol'; |
@@ -20,2 +20,3 @@ /** | ||
isURL, | ||
isPhoneNumber, | ||
isValidAuthority, | ||
@@ -77,2 +78,48 @@ isValidFragment, | ||
describe( 'isPhoneNumber', () => { | ||
it.each( [ | ||
'+1 (555) 123-4567', | ||
'(555) 123-4567', | ||
'555-123-4567', | ||
'5551234567', | ||
'+91 987 654 3210', | ||
'123-456-7890', | ||
'(123) 456-7890', | ||
'123 456 7890', | ||
'123.456.7890', | ||
'+1 123 456 7890', | ||
'1234567890', | ||
'+44 791 112 3456', | ||
'(123) 4567', | ||
'+1 (123) 45678901', | ||
'12-34-56', | ||
'123456789012345', | ||
'+12 3456789012345', | ||
'tel:+1-123-456-7890', | ||
] )( | ||
'returns true when given things that look like a phone number: %s', | ||
( phoneNumber ) => { | ||
expect( isPhoneNumber( phoneNumber ) ).toBe( true ); | ||
} | ||
); | ||
it.each( [ | ||
'not a phone number', | ||
'123', | ||
'1234', | ||
'12345', | ||
'+91 123', | ||
'abc-def-ghij', | ||
'a123456789b', | ||
'12-34-5', | ||
'tel:911', | ||
'tel:12345', | ||
] )( | ||
"returns false when given things that don't look like a phone number: %s", | ||
( phoneNumber ) => { | ||
expect( isPhoneNumber( phoneNumber ) ).toBe( false ); | ||
} | ||
); | ||
} ); | ||
describe( 'getProtocol', () => { | ||
@@ -79,0 +126,0 @@ it( 'returns the protocol part of a URL', () => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
320264
215
4343
573
1