@aws-sdk/util-endpoints 3.190.0 → 3.192.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [3.192.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.191.0...v3.192.0) (2022-10-19)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **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))
12
+
13
+
14
+
15
+
16
+
6
17
  # [3.190.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.189.0...v3.190.0) (2022-10-17)
7
18
 
8
19
 
@@ -10,6 +10,17 @@ const DEFAULT_PORTS = {
10
10
  const parseURL = (value) => {
11
11
  const whatwgURL = (() => {
12
12
  try {
13
+ if (value instanceof URL) {
14
+ return value;
15
+ }
16
+ if (typeof value === "object" && "hostname" in value) {
17
+ const { hostname, port, protocol = "", path = "", query = {} } = value;
18
+ const url = new URL(`${protocol}//${hostname}${port ? `:${port}` : ""}${path}`);
19
+ url.search = Object.entries(query)
20
+ .map(([k, v]) => `${k}=${v}`)
21
+ .join("&");
22
+ return url;
23
+ }
13
24
  return new URL(value);
14
25
  }
15
26
  catch (error) {
@@ -17,8 +28,10 @@ const parseURL = (value) => {
17
28
  }
18
29
  })();
19
30
  if (!whatwgURL) {
31
+ console.error(`Unable to parse ${JSON.stringify(value)} as a whatwg URL.`);
20
32
  return null;
21
33
  }
34
+ const urlString = whatwgURL.href;
22
35
  const { host, hostname, pathname, protocol, search } = whatwgURL;
23
36
  if (search) {
24
37
  return null;
@@ -28,7 +41,9 @@ const parseURL = (value) => {
28
41
  return null;
29
42
  }
30
43
  const isIp = (0, isIpAddress_1.isIpAddress)(hostname);
31
- const authority = `${host}${value.includes(`${host}:${DEFAULT_PORTS[scheme]}`) ? `:${DEFAULT_PORTS[scheme]}` : ``}`;
44
+ const inputContainsDefaultPort = urlString.includes(`${host}:${DEFAULT_PORTS[scheme]}`) ||
45
+ (typeof value === "string" && value.includes(`${host}:${DEFAULT_PORTS[scheme]}`));
46
+ const authority = `${host}${inputContainsDefaultPort ? `:${DEFAULT_PORTS[scheme]}` : ``}`;
32
47
  return {
33
48
  scheme,
34
49
  authority,
@@ -7,6 +7,17 @@ const DEFAULT_PORTS = {
7
7
  export const parseURL = (value) => {
8
8
  const whatwgURL = (() => {
9
9
  try {
10
+ if (value instanceof URL) {
11
+ return value;
12
+ }
13
+ if (typeof value === "object" && "hostname" in value) {
14
+ const { hostname, port, protocol = "", path = "", query = {} } = value;
15
+ const url = new URL(`${protocol}//${hostname}${port ? `:${port}` : ""}${path}`);
16
+ url.search = Object.entries(query)
17
+ .map(([k, v]) => `${k}=${v}`)
18
+ .join("&");
19
+ return url;
20
+ }
10
21
  return new URL(value);
11
22
  }
12
23
  catch (error) {
@@ -14,8 +25,10 @@ export const parseURL = (value) => {
14
25
  }
15
26
  })();
16
27
  if (!whatwgURL) {
28
+ console.error(`Unable to parse ${JSON.stringify(value)} as a whatwg URL.`);
17
29
  return null;
18
30
  }
31
+ const urlString = whatwgURL.href;
19
32
  const { host, hostname, pathname, protocol, search } = whatwgURL;
20
33
  if (search) {
21
34
  return null;
@@ -25,7 +38,9 @@ export const parseURL = (value) => {
25
38
  return null;
26
39
  }
27
40
  const isIp = isIpAddress(hostname);
28
- const authority = `${host}${value.includes(`${host}:${DEFAULT_PORTS[scheme]}`) ? `:${DEFAULT_PORTS[scheme]}` : ``}`;
41
+ const inputContainsDefaultPort = urlString.includes(`${host}:${DEFAULT_PORTS[scheme]}`) ||
42
+ (typeof value === "string" && value.includes(`${host}:${DEFAULT_PORTS[scheme]}`));
43
+ const authority = `${host}${inputContainsDefaultPort ? `:${DEFAULT_PORTS[scheme]}` : ``}`;
29
44
  return {
30
45
  scheme,
31
46
  authority,
@@ -1,5 +1,5 @@
1
- import { EndpointURL } from "@aws-sdk/types";
1
+ import { Endpoint, EndpointURL } from "@aws-sdk/types";
2
2
  /**
3
- * Parses a string into it’s Endpoint URL components.
3
+ * Parses a string, URL, or Endpoint into it’s Endpoint URL components.
4
4
  */
5
- export declare const parseURL: (value: string) => EndpointURL | null;
5
+ export declare const parseURL: (value: string | URL | Endpoint) => EndpointURL | null;
@@ -1,2 +1,4 @@
1
- import { EndpointURL } from "@aws-sdk/types";
2
- export declare const parseURL: (value: string) => EndpointURL | null;
1
+ import { Endpoint, EndpointURL } from "@aws-sdk/types";
2
+ export declare const parseURL: (
3
+ value: string | URL | Endpoint
4
+ ) => EndpointURL | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/util-endpoints",
3
- "version": "3.190.0",
3
+ "version": "3.192.0",
4
4
  "description": "Utilities to help with endpoint resolution",
5
5
  "main": "./dist-cjs/index.js",
6
6
  "module": "./dist-es/index.js",