@google-cloud/storage
Advanced tools
Comparing version 5.0.0 to 5.0.1
@@ -103,2 +103,3 @@ /// <reference types="node" /> | ||
export declare type GetHmacKeysResponse = [HmacKey[]]; | ||
export declare const PROTOCOL_REGEX: RegExp; | ||
/*! Developer Documentation | ||
@@ -325,2 +326,3 @@ * | ||
constructor(options?: StorageOptions); | ||
private static sanitizeEndpoint; | ||
/** | ||
@@ -327,0 +329,0 @@ * Get a reference to a Cloud Storage bucket. |
@@ -16,3 +16,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Storage = void 0; | ||
exports.Storage = exports.PROTOCOL_REGEX = void 0; | ||
const common_1 = require("@google-cloud/common"); | ||
@@ -27,2 +27,3 @@ const paginator_1 = require("@google-cloud/paginator"); | ||
const hmacKey_1 = require("./hmacKey"); | ||
exports.PROTOCOL_REGEX = /^(\w*):\/\//; | ||
/*! Developer Documentation | ||
@@ -94,10 +95,15 @@ * | ||
constructor(options = {}) { | ||
options = Object.assign({}, options, { | ||
apiEndpoint: options.apiEndpoint || 'storage.googleapis.com', | ||
}); | ||
const url = process.env.STORAGE_EMULATOR_HOST || | ||
`https://${options.apiEndpoint}/storage/v1`; | ||
let apiEndpoint = 'https://storage.googleapis.com'; | ||
const EMULATOR_HOST = process.env.STORAGE_EMULATOR_HOST; | ||
if (typeof EMULATOR_HOST === 'string') { | ||
apiEndpoint = Storage.sanitizeEndpoint(EMULATOR_HOST); | ||
} | ||
if (options.apiEndpoint) { | ||
apiEndpoint = Storage.sanitizeEndpoint(options.apiEndpoint); | ||
} | ||
options = Object.assign({}, options, { apiEndpoint }); | ||
const baseUrl = EMULATOR_HOST || `${options.apiEndpoint}/storage/v1`; | ||
const config = { | ||
apiEndpoint: options.apiEndpoint, | ||
baseUrl: url, | ||
baseUrl, | ||
projectIdRequired: false, | ||
@@ -122,2 +128,8 @@ scopes: [ | ||
} | ||
static sanitizeEndpoint(url) { | ||
if (!exports.PROTOCOL_REGEX.test(url)) { | ||
url = `https://${url}`; | ||
} | ||
return url.replace(/\/+$/, ''); // Remove trailing slashes | ||
} | ||
/** | ||
@@ -124,0 +136,0 @@ * Get a reference to a Cloud Storage bucket. |
@@ -7,2 +7,10 @@ # Changelog | ||
### [5.0.1](https://www.github.com/googleapis/nodejs-storage/compare/v5.0.0...v5.0.1) (2020-05-20) | ||
### Bug Fixes | ||
* StorageOptions.apiEndpoint overrides simple and resumable uploads ([#1161](https://www.github.com/googleapis/nodejs-storage/issues/1161)) ([cf8ea5c](https://www.github.com/googleapis/nodejs-storage/commit/cf8ea5cbbecea50233b1681c7f8aba121ec37a1a)) | ||
* **types:** assert in typescript 3.7 ([#1198](https://www.github.com/googleapis/nodejs-storage/issues/1198)) ([d5aa8b7](https://www.github.com/googleapis/nodejs-storage/commit/d5aa8b7892366c9fbbdc33dd001f644da61bb22e)) | ||
## [5.0.0](https://www.github.com/googleapis/nodejs-storage/compare/v4.7.0...v5.0.0) (2020-05-13) | ||
@@ -9,0 +17,0 @@ |
{ | ||
"name": "@google-cloud/storage", | ||
"description": "Cloud Storage Client Library for Node.js", | ||
"version": "5.0.0", | ||
"version": "5.0.1", | ||
"license": "Apache-2.0", | ||
@@ -96,3 +96,3 @@ "author": "Google Inc.", | ||
"@types/tmp": "0.2.0", | ||
"@types/uuid": "^7.0.0", | ||
"@types/uuid": "^8.0.0", | ||
"@types/xdg-basedir": "^2.0.0", | ||
@@ -99,0 +99,0 @@ "c8": "^7.0.0", |
Sorry, the diff of this file is too big to display
518399
10657