@aws-sdk/util-endpoints
Advanced tools
Comparing version 3.190.0 to 3.192.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [3.192.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.191.0...v3.192.0) (2022-10-19) | ||
### Bug Fixes | ||
* **endpoint:** dedupe clientContext/builtIn params, fix s3 unit test ([#4051](https://github.com/aws/aws-sdk-js-v3/issues/4051)) ([947c8bc](https://github.com/aws/aws-sdk-js-v3/commit/947c8bce2798ae5ddc022d34f62aeeb60b4e6fde)) | ||
# [3.190.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.189.0...v3.190.0) (2022-10-17) | ||
@@ -8,0 +19,0 @@ |
@@ -13,2 +13,13 @@ "use strict"; | ||
try { | ||
if (value instanceof URL) { | ||
return value; | ||
} | ||
if (typeof value === "object" && "hostname" in value) { | ||
const { hostname, port, protocol = "", path = "", query = {} } = value; | ||
const url = new URL(`${protocol}//${hostname}${port ? `:${port}` : ""}${path}`); | ||
url.search = Object.entries(query) | ||
.map(([k, v]) => `${k}=${v}`) | ||
.join("&"); | ||
return url; | ||
} | ||
return new URL(value); | ||
@@ -21,4 +32,6 @@ } | ||
if (!whatwgURL) { | ||
console.error(`Unable to parse ${JSON.stringify(value)} as a whatwg URL.`); | ||
return null; | ||
} | ||
const urlString = whatwgURL.href; | ||
const { host, hostname, pathname, protocol, search } = whatwgURL; | ||
@@ -33,3 +46,5 @@ if (search) { | ||
const isIp = (0, isIpAddress_1.isIpAddress)(hostname); | ||
const authority = `${host}${value.includes(`${host}:${DEFAULT_PORTS[scheme]}`) ? `:${DEFAULT_PORTS[scheme]}` : ``}`; | ||
const inputContainsDefaultPort = urlString.includes(`${host}:${DEFAULT_PORTS[scheme]}`) || | ||
(typeof value === "string" && value.includes(`${host}:${DEFAULT_PORTS[scheme]}`)); | ||
const authority = `${host}${inputContainsDefaultPort ? `:${DEFAULT_PORTS[scheme]}` : ``}`; | ||
return { | ||
@@ -36,0 +51,0 @@ scheme, |
@@ -10,2 +10,13 @@ import { EndpointURLScheme } from "@aws-sdk/types"; | ||
try { | ||
if (value instanceof URL) { | ||
return value; | ||
} | ||
if (typeof value === "object" && "hostname" in value) { | ||
const { hostname, port, protocol = "", path = "", query = {} } = value; | ||
const url = new URL(`${protocol}//${hostname}${port ? `:${port}` : ""}${path}`); | ||
url.search = Object.entries(query) | ||
.map(([k, v]) => `${k}=${v}`) | ||
.join("&"); | ||
return url; | ||
} | ||
return new URL(value); | ||
@@ -18,4 +29,6 @@ } | ||
if (!whatwgURL) { | ||
console.error(`Unable to parse ${JSON.stringify(value)} as a whatwg URL.`); | ||
return null; | ||
} | ||
const urlString = whatwgURL.href; | ||
const { host, hostname, pathname, protocol, search } = whatwgURL; | ||
@@ -30,3 +43,5 @@ if (search) { | ||
const isIp = isIpAddress(hostname); | ||
const authority = `${host}${value.includes(`${host}:${DEFAULT_PORTS[scheme]}`) ? `:${DEFAULT_PORTS[scheme]}` : ``}`; | ||
const inputContainsDefaultPort = urlString.includes(`${host}:${DEFAULT_PORTS[scheme]}`) || | ||
(typeof value === "string" && value.includes(`${host}:${DEFAULT_PORTS[scheme]}`)); | ||
const authority = `${host}${inputContainsDefaultPort ? `:${DEFAULT_PORTS[scheme]}` : ``}`; | ||
return { | ||
@@ -33,0 +48,0 @@ scheme, |
@@ -1,5 +0,5 @@ | ||
import { EndpointURL } from "@aws-sdk/types"; | ||
import { Endpoint, EndpointURL } from "@aws-sdk/types"; | ||
/** | ||
* Parses a string into it’s Endpoint URL components. | ||
* Parses a string, URL, or Endpoint into it’s Endpoint URL components. | ||
*/ | ||
export declare const parseURL: (value: string) => EndpointURL | null; | ||
export declare const parseURL: (value: string | URL | Endpoint) => EndpointURL | null; |
@@ -1,2 +0,4 @@ | ||
import { EndpointURL } from "@aws-sdk/types"; | ||
export declare const parseURL: (value: string) => EndpointURL | null; | ||
import { Endpoint, EndpointURL } from "@aws-sdk/types"; | ||
export declare const parseURL: ( | ||
value: string | URL | Endpoint | ||
) => EndpointURL | null; |
{ | ||
"name": "@aws-sdk/util-endpoints", | ||
"version": "3.190.0", | ||
"version": "3.192.0", | ||
"description": "Utilities to help with endpoint resolution", | ||
@@ -5,0 +5,0 @@ "main": "./dist-cjs/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
85592
1769