summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2020-01-06 14:32:30 -0500
committerAnthony G. Basile <blueness@gentoo.org>2020-01-06 14:32:30 -0500
commit10ef81bf85ad0a4bad0d204838e14c99ca2526f7 (patch)
treeb4bb36a326d41de12d1a6181d2a2baf34696ac24 /plugins/jetpack/extensions/blocks/contact-info/phone/save.js
parentUpdating script for Update (diff)
downloadblogs-gentoo-10ef81bf85ad0a4bad0d204838e14c99ca2526f7.tar.gz
blogs-gentoo-10ef81bf85ad0a4bad0d204838e14c99ca2526f7.tar.bz2
blogs-gentoo-10ef81bf85ad0a4bad0d204838e14c99ca2526f7.zip
Update jetpack 8.0
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'plugins/jetpack/extensions/blocks/contact-info/phone/save.js')
-rw-r--r--plugins/jetpack/extensions/blocks/contact-info/phone/save.js47
1 files changed, 0 insertions, 47 deletions
diff --git a/plugins/jetpack/extensions/blocks/contact-info/phone/save.js b/plugins/jetpack/extensions/blocks/contact-info/phone/save.js
deleted file mode 100644
index 50f67914..00000000
--- a/plugins/jetpack/extensions/blocks/contact-info/phone/save.js
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Internal dependencies
- */
-
-export function renderPhone( inputText ) {
- const arrayOfNumbers = inputText.match( /\d+\.\d+|\d+\b|\d+(?=\w)/g );
- if ( ! arrayOfNumbers ) {
- // No numbers found
- return inputText;
- }
- const indexOfFirstNumber = inputText.indexOf( arrayOfNumbers[ 0 ] );
-
- // Assume that eveything after the first number should be part of the phone number.
- // care about the first prefix character.
- let phoneNumber = indexOfFirstNumber ? inputText.substring( indexOfFirstNumber - 1 ) : inputText;
- let prefix = indexOfFirstNumber ? inputText.substring( 0, indexOfFirstNumber ) : '';
-
- let justNumber = phoneNumber.replace( /\D/g, '' );
- // Phone numbers starting with + should be part of the number.
- if ( /[0-9/+/(]/.test( phoneNumber[ 0 ] ) ) {
- // Remove the special character from the prefix so they don't appear twice.
- prefix = prefix.slice( 0, -1 );
- // Phone numbers starting with + shoud be part of the number.
- if ( phoneNumber[ 0 ] === '+' ) {
- justNumber = '+' + justNumber;
- }
- } else {
- // Remove the first character.
- phoneNumber = phoneNumber.substring( 1 );
- }
- const prefixSpan = prefix.trim() ? (
- <span key="phonePrefix" className="phone-prefix">
- { prefix }
- </span>
- ) : null;
- return [
- prefixSpan,
- <a key="phoneNumber" href={ `tel:${ justNumber }` }>
- { phoneNumber }
- </a>,
- ];
-}
-
-const save = ( { attributes: { phone }, className } ) =>
- phone && <div className={ className }>{ renderPhone( phone ) }</div>;
-
-export default save;