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

@compas/stdlib

Package Overview
Dependencies
Maintainers
1
Versions
196
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@compas/stdlib - npm Package Compare versions

Comparing version 0.0.127 to 0.0.128

2

index.js

@@ -10,2 +10,4 @@ export { uuid } from "./src/datatypes.js";

refreshEnvironmentCache,
calculateCorsUrlFromAppUrl,
calculateCookieUrlFromAppUrl,
} from "./src/env.js";

@@ -12,0 +14,0 @@

6

package.json
{
"name": "@compas/stdlib",
"version": "0.0.127",
"version": "0.0.128",
"description": "All kinds of utility functions",

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

"dependencies": {
"@compas/insight": "0.0.127",
"@compas/insight": "0.0.128",
"@types/node": "14.14.37",

@@ -43,3 +43,3 @@ "dotenv": "8.2.0",

},
"gitHead": "5bc1438cddeb96b50f0395f7de18ba5c1c5b8c91"
"gitHead": "0ca512dd447ebebc6c6793e2728cfb4c172b0181"
}

@@ -59,1 +59,56 @@ /**

}
/**
* Try to calculate the CORS_URL environment variable from the APP_URL environment
* variable. Assumes the APP_URL is in the following format: http(s)://api.xxx.xx.com and
* generates the following CORS_URL value: http(s)://xxx.xx.com.
* If the APP_URL host only contains xxx.com the CORS_URL value will be equivalent.
*
* Refreshing the environment cache via `refreshEnvironmentCache` is not necessary.
*
* @since 0.1.0
*
* @returns {void}
*/
export function calculateCorsUrlFromAppUrl() {
const appUrl = new URL(environment.APP_URL);
const hostParts = appUrl.host.split(".");
const protocol = appUrl.protocol;
let corsUrl = "";
if (hostParts.length === 2) {
corsUrl = `${protocol}//${appUrl.host}`;
} else {
corsUrl = `${protocol}//${hostParts.slice(1).join(".")}`;
}
environment.CORS_URL = corsUrl;
process.env.CORS_URL = corsUrl;
}
/**
* Try to calculate the COOKIE_URL environment variable from the APP_URL environment
* variable. Assumes the APP_URL is in the following format: http(s)://api.xxx.xx.com and
* generates the following COOKIE_URL value: xxx.xx.com.
* If the APP_URL host only contains xxx.com the CORS_URL value will be equivalent.
*
* Refreshing the environment cache via `refreshEnvironmentCache` is not necessary.
*
* @since 0.1.0
*
* @returns {void}
*/
export function calculateCookieUrlFromAppUrl() {
const appUrl = new URL(environment.APP_URL);
const hostParts = appUrl.host.split(".");
let cookieUrl = appUrl.host;
if (hostParts.length !== 2) {
cookieUrl = hostParts.slice(1).join(".");
}
environment.COOKIE_URL = cookieUrl;
process.env.COOKIE_URL = cookieUrl;
}
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