Skip to content

Commit 9842c06

Browse files
authored
fix lint
1 parent 3d36843 commit 9842c06

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

.devcontainer/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/vscode/devcontainers/rust:1-bullseye
1+
FROM mcr.microsoft.com/devcontainers/rust:1
22

33
# Install cmake
44
RUN apt-get update \

ext/fetch/22_http_client.js

+19-8
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ import { op_fetch_custom_client } from "ext:core/ops";
1717
import { loadTlsKeyPair } from "ext:deno_net/02_tls.js";
1818

1919
const { internalRidSymbol } = core;
20-
const { ObjectDefineProperty } = primordials;
20+
const {
21+
JSONStringify,
22+
ObjectDefineProperty,
23+
ObjectHasOwn,
24+
StringPrototypeStartsWith,
25+
TypeError,
26+
} = primordials;
2127

2228
/**
2329
* @param {Deno.CreateHttpClientOptions} options
@@ -26,13 +32,14 @@ const { ObjectDefineProperty } = primordials;
2632
function createHttpClient(options) {
2733
options.caCerts ??= [];
2834
if (options.proxy) {
29-
if ("transport" in options.proxy) {
35+
if (ObjectHasOwn(options.proxy, "transport")) {
3036
switch (options.proxy.transport) {
3137
case "http": {
3238
const url = options.proxy.url;
3339
if (
34-
url.startsWith("https:") || url.startsWith("socks5:") ||
35-
url.startsWith("socks5h:")
40+
StringPrototypeStartsWith(url, "https:") ||
41+
StringPrototypeStartsWith(url, "socks5:") ||
42+
StringPrototypeStartsWith(url, "socks5h:")
3643
) {
3744
throw new TypeError(
3845
`The url passed into 'proxy.url' has an invalid scheme for this transport.`,
@@ -44,8 +51,9 @@ function createHttpClient(options) {
4451
case "https": {
4552
const url = options.proxy.url;
4653
if (
47-
url.startsWith("http:") || url.startsWith("socks5:") ||
48-
url.startsWith("socks5h:")
54+
StringPrototypeStartsWith(url, "http:") ||
55+
StringPrototypeStartsWith(url, "socks5:") ||
56+
StringPrototypeStartsWith(url, "socks5h:")
4957
) {
5058
throw new TypeError(
5159
`The url passed into 'proxy.url' has an invalid scheme for this transport.`,
@@ -56,7 +64,10 @@ function createHttpClient(options) {
5664
}
5765
case "socks5": {
5866
const url = options.proxy.url;
59-
if (!url.startsWith("socks5:") || !url.startsWith("socks5h:")) {
67+
if (
68+
!StringPrototypeStartsWith(url, "socks5:") ||
69+
!StringPrototypeStartsWith(url, "socks5h:")
70+
) {
6071
throw new TypeError(
6172
`The url passed into 'proxy.url' has an invalid scheme for this transport.`,
6273
);
@@ -70,7 +81,7 @@ function createHttpClient(options) {
7081
default: {
7182
throw new TypeError(
7283
`Invalid value for 'proxy.transport' option: ${
73-
JSON.stringify(options.proxy.transport)
84+
JSONStringify(options.proxy.transport)
7485
}`,
7586
);
7687
}

0 commit comments

Comments
 (0)