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

cloud-url-resolver

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloud-url-resolver - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

34

dist/index.js

@@ -6,2 +6,19 @@ const inBrowser = typeof window !== "undefined";

});
const protocolRegex = /^https?:\/\//;
const workspaceDefinedError = Error("workspace url not defined");
function transformWithEndingPort(port, resolvedProtocol, origin, regex, replacer) {
const url = origin.replace(regex, "").replace(protocolRegex, "");
if (!url) {
throw workspaceDefinedError;
}
return `${resolvedProtocol}://${url}${port}.${replacer}`;
}
function transformWithStartingPort(port, resolvedProtocol, origin) {
const regex = /^https?:\/\/\d{1,5}/;
const url = origin.replace(regex, "");
if (!url) {
throw workspaceDefinedError;
}
return `${resolvedProtocol}://${port}${url}`;
}
/**

@@ -17,18 +34,9 @@ * Cloud URL transformation function. Designed to run on either SSR or browser.

if (origin.endsWith("gitpod.io")) {
const regex = /^https?:\/\/\d{1,5}/;
const url = origin.replace(regex, "");
if (!url) {
throw Error("workspace url not defined");
}
return `${resolvedProtocol}://${port}${url}`;
return transformWithStartingPort(port, resolvedProtocol, origin);
} else if (origin.endsWith("app.github.dev")) {
const protocolRegex = /^https?:\/\//;
const regex = /\d{1,5}\.app\.github\.dev$/;
const url = origin.replace(regex, "").replace(protocolRegex, "");
if (!url) {
throw Error("workspace url not defined");
}
return `${resolvedProtocol}://${url}${port}.app.github.dev`;
return transformWithEndingPort(port, resolvedProtocol, origin, /\d{1,5}\.app\.github\.dev$/, "app.github.dev");
} else if (origin.endsWith("glitch.me")) {
return `${resolvedProtocol}://${new URL(origin).host}`;
} else if (origin.endsWith("csb.app")) {
return transformWithEndingPort(port, resolvedProtocol, origin, /\d{1,5}\.csb\.app$/, "csb.app");
}

@@ -35,0 +43,0 @@ }

{
"name": "cloud-url-resolver",
"version": "1.1.0",
"version": "1.2.0",
"description": "Allow changing the port and protocol of any common development url",

@@ -5,0 +5,0 @@ "repository": {

# cloud-url-resolver
![NPM Version](https://img.shields.io/npm/v/cloud-url-resolver)
[![NPM Version](https://img.shields.io/npm/v/cloud-url-resolver)](https://npmjs.com/package/cloud-url-resolver)

@@ -12,2 +12,3 @@ easily resolve protocol/port setups on any development platform

- [Glitch](https://glitch.com/) - _no port support_
- [CodeSandbox](https://codesandbox.io)

@@ -14,0 +15,0 @@ If you would like to add support for another platform, please open an issue about it.

Sorry, the diff of this file is not supported yet

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