Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

poly-js-utils

Package Overview
Dependencies
Maintainers
2
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

poly-js-utils - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

2

package.json
{
"name": "poly-js-utils",
"version": "1.2.0",
"version": "1.2.1",
"description": "Common client-side tools used in HSS Sites themes and locators.",

@@ -5,0 +5,0 @@ "main": "main.js",

@@ -24,4 +24,4 @@ var viewHelpers = require('../src/view-helpers');

it("should correctly format 10-digit phone numbers for pretty formatting with prefix", function() {
var phone = "+5551234567";
var expected = "+55-5123-4567";
var phone = "+555-123-4567";
var expected = "+5551234567";
expect(viewHelpers.phoneFormat(phone, true)).toBe(expected);

@@ -37,31 +37,13 @@ });

it("should correctly format 11-digit phone numbers for pretty formatting with prefix", function() {
var phone = "+15551234567";
var expected = "+1-555-123-4567";
var phone = "+1-555-123-4567";
var expected = "+15551234567";
expect(viewHelpers.phoneFormat(phone, true)).toBe(expected);
});
it("should correctly format 12-digit phone numbers for pretty formatting", function() {
var phone = "555123456789";
var expected = "55-51234-56789";
expect(viewHelpers.phoneFormat(phone, true)).toBe(expected);
});
it("should correctly format 12-digit phone numbers for pretty formatting with prefix", function() {
it("should correctly format international phone numbers for pretty formatting", function() {
var phone = "+555123456789";
var expected = "+55-51234-56789";
var expected = "+555123456789";
expect(viewHelpers.phoneFormat(phone, true)).toBe(expected);
});
it("should correctly format 13-digit phone numbers for pretty formatting", function() {
var phone = "5551234567890";
var expected = "55-512-345-67890";
expect(viewHelpers.phoneFormat(phone, true)).toBe(expected);
});
it("should correctly format 13-digit phone numbers for pretty formatting with prefix", function() {
var phone = "+5551234567890";
var expected = "+55-512-345-67890";
expect(viewHelpers.phoneFormat(phone, true)).toBe(expected);
});
it("should know if the 10-digit number has an extension, and make that pretty too", function() {

@@ -68,0 +50,0 @@ var phone = "555 123-4567 x 42";

@@ -71,26 +71,10 @@ /****************************/

}
if (digits.length === 13) {
return prefix + digits.replace(/(\d{2})(\d{3})(\d{3})(\d{5})/, '$1-$2-$3-$4') + extension;
if (digits.length === 11 && !prefix) {
return digits.replace(/(\d{1})(\d{3})(\d{3})(\d{4})/, '$1 ($2) $3-$4') + extension;
}
else if (digits.length === 12) {
return prefix + digits.replace(/(\d{2})(\d{5})(\d{5})/, '$1-$2-$3') + extension;
else if (digits.length === 10 && !prefix) {
return digits.replace(/(\d{3})(\d{3})(\d{4})/, '($1) $2-$3') + extension;
}
else if (digits.length === 11) {
if (prefix === "") {
return digits.replace(/(\d{1})(\d{3})(\d{3})(\d{4})/, '$1 ($2) $3-$4') + extension;
}
else {
return prefix + digits.replace(/(\d{1})(\d{3})(\d{3})(\d{4})/, '$1-$2-$3-$4') + extension;
}
}
else if (digits.length === 10) {
if (prefix === "") {
return digits.replace(/(\d{3})(\d{3})(\d{4})/, '($1) $2-$3') + extension;
}
else {
return prefix + digits.replace(/(\d{2})(\d{4})(\d{4})/, '$1-$2-$3') + extension;
}
}
else {
return phone + extension;
return prefix + digits + extension;
}

@@ -97,0 +81,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc