Files
headroom/frontend/node_modules/libphonenumber-js/build/helpers/extractFormattedPhoneNumberFromPossibleRfc3966NumberUri.js
Santhosh Janardhanan de2d83092e feat: Reinitialize frontend with SvelteKit and TypeScript
- Delete old Vite+Svelte frontend
- Initialize new SvelteKit project with TypeScript
- Configure Tailwind CSS v4 + DaisyUI
- Implement JWT authentication with auto-refresh
- Create login page with form validation (Zod)
- Add protected route guards
- Update Docker configuration for single-stage build
- Add E2E tests with Playwright (6/11 passing)
- Fix Svelte 5 reactivity with $state() runes

Known issues:
- 5 E2E tests failing (timing/async issues)
- Token refresh implementation needs debugging
- Validation error display timing
2026-02-17 16:19:59 -05:00

73 lines
4.2 KiB
JavaScript

"use strict";
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = extractFormattedPhoneNumberFromPossibleRfc3966NumberUri;
var _extractPhoneContext = _interopRequireWildcard(require("./extractPhoneContext.js"));
var _ParseError = _interopRequireDefault(require("../ParseError.js"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
/**
* @param {string} numberToParse
* @param {string} nationalNumber
* @return {}
*/
function extractFormattedPhoneNumberFromPossibleRfc3966NumberUri(numberToParse, _ref) {
var extractFormattedPhoneNumber = _ref.extractFormattedPhoneNumber;
var phoneContext = (0, _extractPhoneContext["default"])(numberToParse);
if (!(0, _extractPhoneContext.isPhoneContextValid)(phoneContext)) {
throw new _ParseError["default"]('NOT_A_NUMBER');
}
var phoneNumberString;
if (phoneContext === null) {
// Extract a possible number from the string passed in.
// (this strips leading characters that could not be the start of a phone number)
phoneNumberString = extractFormattedPhoneNumber(numberToParse) || '';
} else {
phoneNumberString = '';
// If the phone context contains a phone number prefix, we need to capture
// it, whereas domains will be ignored.
if (phoneContext.charAt(0) === _extractPhoneContext.PLUS_SIGN) {
phoneNumberString += phoneContext;
}
// Now append everything between the "tel:" prefix and the phone-context.
// This should include the national number, an optional extension or
// isdn-subaddress component. Note we also handle the case when "tel:" is
// missing, as we have seen in some of the phone number inputs.
// In that case, we append everything from the beginning.
var indexOfRfc3966Prefix = numberToParse.indexOf(_extractPhoneContext.RFC3966_PREFIX_);
var indexOfNationalNumber;
// RFC 3966 "tel:" prefix is preset at this stage because
// `isPhoneContextValid()` requires it to be present.
/* istanbul ignore else */
if (indexOfRfc3966Prefix >= 0) {
indexOfNationalNumber = indexOfRfc3966Prefix + _extractPhoneContext.RFC3966_PREFIX_.length;
} else {
indexOfNationalNumber = 0;
}
var indexOfPhoneContext = numberToParse.indexOf(_extractPhoneContext.RFC3966_PHONE_CONTEXT_);
phoneNumberString += numberToParse.substring(indexOfNationalNumber, indexOfPhoneContext);
}
// Delete the isdn-subaddress and everything after it if it is present.
// Note extension won't appear at the same time with isdn-subaddress
// according to paragraph 5.3 of the RFC3966 spec.
var indexOfIsdn = phoneNumberString.indexOf(_extractPhoneContext.RFC3966_ISDN_SUBADDRESS_);
if (indexOfIsdn > 0) {
phoneNumberString = phoneNumberString.substring(0, indexOfIsdn);
}
// If both phone context and isdn-subaddress are absent but other
// parameters are present, the parameters are left in nationalNumber.
// This is because we are concerned about deleting content from a potential
// number string when there is no strong evidence that the number is
// actually written in RFC3966.
if (phoneNumberString !== '') {
return phoneNumberString;
}
}
//# sourceMappingURL=extractFormattedPhoneNumberFromPossibleRfc3966NumberUri.js.map