Comparing version 10.0.3 to 10.0.4
@@ -71,3 +71,3 @@ "use strict"; | ||
} | ||
// Fallback to `utf8` | ||
// Fall back to `utf8` | ||
response.body = body.toString(); | ||
@@ -74,0 +74,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const url_1 = require("url"); | ||
const util_1 = require("util"); | ||
@@ -196,2 +197,3 @@ const CacheableRequest = require("cacheable-request"); | ||
if (is_1.default.urlInstance(url) || is_1.default.string(url)) { | ||
// @ts-ignore URL is not URL | ||
options.url = url; | ||
@@ -230,3 +232,3 @@ options = exports.mergeOptions((_b = (_a = defaults) === null || _a === void 0 ? void 0 : _a.options, (_b !== null && _b !== void 0 ? _b : {})), options); | ||
} | ||
normalizedOptions.url = new URL(value + normalizedOptions.url.href.slice(prefixUrl.length)); | ||
normalizedOptions.url = new url_1.URL(value + normalizedOptions.url.href.slice(prefixUrl.length)); | ||
prefixUrl = value; | ||
@@ -290,3 +292,3 @@ }, | ||
} | ||
options.body = (new URLSearchParams(options.form)).toString(); | ||
options.body = (new url_1.URLSearchParams(options.form)).toString(); | ||
} | ||
@@ -293,0 +295,0 @@ else if (options.json) { |
@@ -7,2 +7,3 @@ "use strict"; | ||
const stream = require("stream"); | ||
const url_1 = require("url"); | ||
const util_1 = require("util"); | ||
@@ -97,3 +98,3 @@ const is_1 = require("@sindresorhus/is"); | ||
const redirectBuffer = Buffer.from(typedResponse.headers.location, 'binary').toString(); | ||
const redirectURL = new URL(redirectBuffer, options.url); | ||
const redirectURL = new url_1.URL(redirectBuffer, options.url); | ||
// Redirecting to a different site, clear cookies. | ||
@@ -128,7 +129,7 @@ if (redirectURL.hostname !== options.url.hostname) { | ||
const handleRequest = async (request) => { | ||
let piped = false; | ||
let finished = false; | ||
let isPiped = false; | ||
let isFinished = false; | ||
// `request.finished` doesn't indicate whether this has been emitted or not | ||
request.once('finish', () => { | ||
finished = true; | ||
isFinished = true; | ||
}); | ||
@@ -148,5 +149,5 @@ currentRequest = request; | ||
request.on('error', error => { | ||
if (piped) { | ||
if (isPiped) { | ||
// Check if it's caught by `stream.pipeline(...)` | ||
if (!finished) { | ||
if (!isFinished) { | ||
return; | ||
@@ -166,3 +167,3 @@ } | ||
const uploadStream = progress_1.createProgressStream('uploadProgress', emitter, httpOptions.headers['content-length']); | ||
piped = true; | ||
isPiped = true; | ||
await pipeline(httpOptions.body, uploadStream, request); | ||
@@ -200,3 +201,3 @@ request.emit('upload-complete'); | ||
try { | ||
// @ts-ignore URLSearchParams does not equal URLSearchParams | ||
// @ts-ignore ResponseObject does not equal IncomingMessage | ||
handleRequest(httpOptions.request(options.url, httpOptions, handleResponse)); | ||
@@ -203,0 +204,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const url_1 = require("url"); | ||
const is_1 = require("@sindresorhus/is"); | ||
@@ -10,3 +11,3 @@ function merge(target, ...sources) { | ||
// @ts-ignore TS doesn't recognise Target accepts string keys | ||
target[key] = new URL(sourceValue, targetValue); | ||
target[key] = new url_1.URL(sourceValue, targetValue); | ||
} | ||
@@ -13,0 +14,0 @@ else if (is_1.default.plainObject(sourceValue)) { |
@@ -0,1 +1,3 @@ | ||
/// <reference types="node" /> | ||
import { URL, URLSearchParams } from 'url'; | ||
export interface URLOptions { | ||
@@ -2,0 +4,0 @@ href?: string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const url_1 = require("url"); | ||
function validateSearchParams(searchParams) { | ||
@@ -42,3 +43,3 @@ for (const value of Object.values(searchParams)) { | ||
if (options.href) { | ||
return new URL(options.href); | ||
return new url_1.URL(options.href); | ||
} | ||
@@ -54,3 +55,3 @@ if (options.origin) { | ||
} | ||
const url = new URL(origin); | ||
const url = new url_1.URL(origin); | ||
if (options.path) { | ||
@@ -75,6 +76,6 @@ const searchIndex = options.path.indexOf('?'); | ||
if (options.searchParams) { | ||
if (typeof options.searchParams !== 'string' && !(options.searchParams instanceof URLSearchParams)) { | ||
if (typeof options.searchParams !== 'string' && !(options.searchParams instanceof url_1.URLSearchParams)) { | ||
validateSearchParams(options.searchParams); | ||
} | ||
(new URLSearchParams(options.searchParams)).forEach((value, key) => { | ||
(new url_1.URLSearchParams(options.searchParams)).forEach((value, key) => { | ||
url.searchParams.append(key, value); | ||
@@ -81,0 +82,0 @@ }); |
@@ -8,2 +8,3 @@ /// <reference types="node" /> | ||
import ResponseLike = require('responselike'); | ||
import { URL } from 'url'; | ||
import { Readable as ReadableStream } from 'stream'; | ||
@@ -182,39 +183,2 @@ import { Timings } from '@szmarczak/http-timer'; | ||
} | ||
declare global { | ||
class URL { | ||
readonly origin: string; | ||
readonly searchParams: URLSearchParams; | ||
hash: string; | ||
host: string; | ||
hostname: string; | ||
href: string; | ||
password: string; | ||
pathname: string; | ||
port: string; | ||
protocol: string; | ||
search: string; | ||
username: string; | ||
constructor(input: string, base?: string | URL); | ||
toString(): string; | ||
toJSON(): string; | ||
} | ||
class URLSearchParams implements Iterable<[string, string]> { | ||
constructor(init?: URLSearchParams | string | { | ||
[key: string]: string | string[] | undefined; | ||
} | Iterable<[string, string]> | Array<[string, string]>); | ||
append(name: string, value: string): void; | ||
delete(name: string): void; | ||
entries(): IterableIterator<[string, string]>; | ||
forEach(callback: (value: string, name: string, searchParams: this) => void): void; | ||
get(name: string): string | null; | ||
getAll(name: string): string[]; | ||
has(name: string): boolean; | ||
keys(): IterableIterator<string>; | ||
set(name: string, value: string): void; | ||
sort(): void; | ||
toString(): string; | ||
values(): IterableIterator<string>; | ||
[Symbol.iterator](): IterableIterator<[string, string]>; | ||
} | ||
} | ||
export {}; |
/// <reference types="node" /> | ||
import { UrlWithStringQuery } from 'url'; | ||
import { URL, UrlWithStringQuery } from 'url'; | ||
export interface LegacyURLOptions { | ||
@@ -4,0 +4,0 @@ protocol: string; |
{ | ||
"name": "got", | ||
"version": "10.0.3", | ||
"version": "10.0.4", | ||
"description": "Human-friendly and powerful HTTP request library for Node.js", | ||
@@ -128,5 +128,7 @@ "license": "MIT", | ||
"rules": { | ||
"@typescript-eslint/no-empty-function": "off" | ||
"@typescript-eslint/no-empty-function": "off", | ||
"node/prefer-global/url": "off", | ||
"node/prefer-global/url-search-params": "off" | ||
} | ||
} | ||
} |
@@ -125,3 +125,3 @@ <div align="center"> | ||
**Note:** Legacy Url support is disabled. `options.path` is supported only for backwards compatibility. Instead of the `options.auth`, you should use `options.username` and/or `options.password`. | ||
**Note:** Legacy URL support is disabled. `options.path` is supported only for backwards compatibility. Instead of the `options.auth`, you should use `options.username` and/or `options.password`. | ||
@@ -128,0 +128,0 @@ ###### prefixUrl |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
5
152250
2236