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

@nuskin/ns-common-lib

Package Overview
Dependencies
Maintainers
5
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nuskin/ns-common-lib - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

24

__tests__/urls.spec.js
/* eslint-disable max-len */
const { getFullUrl, getUrlWithExtention } = require("../src/urls");
const { getFullUrl, getUrlWithExtention, getEnvironmentFromUrl } = require("../src/urls");

@@ -31,1 +31,23 @@ describe("[urls.js] getFullUrl", () => {

});
describe("[urls.js] getEnvironmentFromUrl", () => {
test("Can call getEnvironmentFromUrl and get 'dev'", () => {
const baseUrl = "https://dev.nuskin.com";
expect(getEnvironmentFromUrl(baseUrl)).toBe('dev');
});
test("Can call getEnvironmentFromUrl and get 'test'", () => {
const baseUrl = "https://test.nuskin.com";
expect(getEnvironmentFromUrl(baseUrl)).toBe('test');
});
test("Can call getEnvironmentFromUrl and get 'stage'", () => {
const baseUrl = "https://stage.nuskin.com";
expect(getEnvironmentFromUrl(baseUrl)).toBe('stage');
});
test("Can call getEnvironmentFromUrl and get 'prod'", () => {
const baseUrl = "https://www.nuskin.com";
expect(getEnvironmentFromUrl(baseUrl)).toBe('prod');
});
});

@@ -0,1 +1,12 @@

# [1.2.0](https://code.tls.nuskin.io/ns-am/utility/npm/ns-common-lib/compare/v1.1.0...v1.2.0) (2021-04-02)
### Chore
* minor changes with project moved to new location in GitLab ([c8374eb](https://code.tls.nuskin.io/ns-am/utility/npm/ns-common-lib/commit/c8374eb160f8c4078b4f4d6d2b2a8696d9e298e8))
### Update
* added getEnvironmentFromUrl (#CX12-3039) ([8047df6](https://code.tls.nuskin.io/ns-am/utility/npm/ns-common-lib/commit/8047df61832181772c6dcecae09143d3d959e740)), closes [#CX12-3039](https://code.tls.nuskin.io/ns-am/utility/npm/ns-common-lib/issues/CX12-3039)
# [1.1.0](https://code.tls.nuskin.io/ns-am/platform/ns-common-lib/compare/v1.0.0...v1.1.0) (2020-10-22)

@@ -2,0 +13,0 @@

6

package.json
{
"name": "@nuskin/ns-common-lib",
"version": "1.1.0",
"version": "1.2.0",
"description": "This project contains shared common models and code between the backend and frontend.",

@@ -15,3 +15,3 @@ "main": "src/index.js",

"type": "git",
"url": "git@code.tls.nuskin.io:ns-am/platform/ns-common-lib.git"
"url": "git@code.tls.nuskin.io:ns-am/utility/npm/ns-common-lib.git"
},

@@ -21,3 +21,3 @@ "keywords": [],

"license": "ISC",
"homepage": "https://code.tls.nuskin.io/ns-am/platform/ns-common-lib/blob/master/README.md",
"homepage": "https://code.tls.nuskin.io/ns-am/utility/npm/ns-common-lib/-/blob/master/README.md",
"devDependencies": {

@@ -24,0 +24,0 @@ "eslint": "5.16.0",

@@ -11,3 +11,7 @@ /**

const { fromJsonString } = require("./json");
const { getFullUrl, getUrlWithExtention } = require("./urls");
const {
getFullUrl,
getUrlWithExtention,
getEnvironmentFromUrl
} = require("./urls");
const { arrayDifference } = require("./arrays");

@@ -23,4 +27,5 @@ const { getLocaleInfo } = require("./locale");

getUrlWithExtention,
getEnvironmentFromUrl,
arrayDifference,
getLocaleInfo
};

@@ -39,5 +39,96 @@ "use strict";

/**
* Environment URLs
* Note: These values were copied from ns-util runConfigService.js
*/
const environmentUrls = {
local: "localhost",
local4502: "localhost:4502",
test: "test.nuskin.com",
testStorefront: "test.mynuskin.com",
testCloud: "tst.nuskin.io",
dev: "dev.nuskin.com",
devCloud: "dev.nuskin.io",
prod: "www.nuskin.com",
prodStorefront: ".mynuskin.com",
prodCloud: "www.nuskin.io",
stage: "stage.nuskin.com",
stageCloud: "stg.nuskin.io",
feature: "dev.usw2.nuskin.io"
};
/**
* Dev Environment URLs
*/
const devEnvironmentUrls = [environmentUrls.dev, environmentUrls.devCloud];
/**
* Test Environment URLs
*/
const testEnvironmentUrls = [
environmentUrls.test,
environmentUrls.testStorefront,
environmentUrls.feature,
environmentUrls.testCloud,
environmentUrls.local,
environmentUrls.local4502
];
/**
* Stage Environment URLs
*/
const stageEnvironmentUrls = [
environmentUrls.stage,
environmentUrls.stageCloud
];
/**
* Prod Environment URLs
*/
const prodEnvironmentUrls = [
environmentUrls.prod,
environmentUrls.prodCloud,
environmentUrls.prodStorefront
];
/**
* This attempts to get the environment based on the URL of nuskin.com known addresses.
* @param {String} url
*/
function getEnvironmentFromUrl(url) {
if (url) {
// check if 'dev' environment
if (devEnvironmentUrls.some((envUrl) => url.includes(envUrl))) {
return "dev";
}
// check if 'test' environment
if (testEnvironmentUrls.some((e) => url.includes(e))) {
return "test";
}
// check if 'stage' environment
if (stageEnvironmentUrls.some((envUrl) => url.includes(envUrl))) {
return "stage";
}
// check if 'prod' environment
if (prodEnvironmentUrls.some((envUrl) => url.includes(envUrl))) {
return "prod";
}
}
// environment is not known
return "unknown";
}
module.exports = {
getFullUrl,
getUrlWithExtention
getUrlWithExtention,
environmentUrls,
devEnvironmentUrls,
testEnvironmentUrls,
stageEnvironmentUrls,
prodEnvironmentUrls,
getEnvironmentFromUrl
};
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