@aarhus-university/au-lib-react-components 9.11.17 → 9.11.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/lib/helpers.js +12 -9
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"sideEffects": false,
|
|
3
3
|
"name": "@aarhus-university/au-lib-react-components",
|
|
4
|
-
"version": "9.11.
|
|
4
|
+
"version": "9.11.18",
|
|
5
5
|
"description": "Library for shared React components for various applications on au.dk",
|
|
6
6
|
"main": "build/cjs/index.js",
|
|
7
7
|
"scripts": {
|
package/src/lib/helpers.js
CHANGED
|
@@ -156,17 +156,20 @@ const splitPhoneNumber = (countryCodes, phoneNumber) => {
|
|
|
156
156
|
).length > 0;
|
|
157
157
|
|
|
158
158
|
const findPrefix = () => {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
159
|
+
if (countryCodes.length > 0) {
|
|
160
|
+
const skip = '';
|
|
161
|
+
let count = 1;
|
|
162
|
+
let prefix = countryCodes.find((x) => x.important).code;
|
|
163
|
+
while (count < phoneNumber.length) {
|
|
164
|
+
const split = phoneNumber.substring(skip.length, skip.length + count);
|
|
165
|
+
if (countryCodeFound(split)) {
|
|
166
|
+
prefix = split;
|
|
167
|
+
}
|
|
168
|
+
count += 1;
|
|
166
169
|
}
|
|
167
|
-
|
|
170
|
+
return skip + prefix;
|
|
168
171
|
}
|
|
169
|
-
return
|
|
172
|
+
return '';
|
|
170
173
|
};
|
|
171
174
|
|
|
172
175
|
const prefix = findPrefix();
|