@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. 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.17",
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": {
@@ -156,17 +156,20 @@ const splitPhoneNumber = (countryCodes, phoneNumber) => {
156
156
  ).length > 0;
157
157
 
158
158
  const findPrefix = () => {
159
- const skip = '+';
160
- let count = 1;
161
- let prefix = countryCodes.find((x) => x.important).code;
162
- while (count < phoneNumber.length) {
163
- const split = phoneNumber.substring(skip.length, skip.length + count);
164
- if (countryCodeFound(split)) {
165
- prefix = split;
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
- count += 1;
170
+ return skip + prefix;
168
171
  }
169
- return skip + prefix;
172
+ return '';
170
173
  };
171
174
 
172
175
  const prefix = findPrefix();