Comparing version 0.0.1-alpha.1 to 0.0.1-alpha.2
@@ -7,5 +7,17 @@ All notable changes to this project will be documented in this file. | ||
## [UNRELEASED] | ||
(nothing yet) | ||
## [0.0.1-alpha.2] - 2019-01-03 | ||
### Added | ||
- base url support | ||
### Fixed | ||
- eslint not actually linting because of `mjs` extension | ||
## [0.0.1-alpha.1] - 2018-12-01 | ||
### Added | ||
- first version with working basics | ||
## [0.0.0] - 2018-11-29 | ||
### Added | ||
- npm name reserved |
@@ -12,2 +12,4 @@ "use strict"; | ||
var _urlJoin = _interopRequireDefault(require("url-join")); | ||
var _errors = require("./errors"); | ||
@@ -61,2 +63,10 @@ | ||
var safeUrlParse = function safeUrlParse(url) { | ||
try { | ||
return new URL(url); | ||
} catch (e) { | ||
// eslint-disable-line no-unused-vars | ||
return null; | ||
} | ||
}; | ||
/** | ||
@@ -66,2 +76,3 @@ * @class ApiClient | ||
var ApiClient = | ||
@@ -128,12 +139,33 @@ /*#__PURE__*/ | ||
}, { | ||
key: "_buildUrlBase", | ||
value: function _buildUrlBase(url, base) { | ||
var parsedBase = safeUrlParse(base); | ||
if (!parsedBase || !parsedBase.host) { | ||
// @todo throw an Error ? | ||
return url; | ||
} | ||
var parsedUrl = safeUrlParse(url); | ||
if (parsedUrl && parsedUrl.base) { | ||
// base is valid full url and given url is also full url | ||
throw new Error("Cannot use absolute url with base url."); // @todo throw custom type? | ||
} | ||
return (0, _urlJoin.default)(base, url); | ||
} | ||
}, { | ||
key: "_buildUrl", | ||
value: function _buildUrl(originalUrl, queryParams) { | ||
value: function _buildUrl(originalUrl, queryParams, fetchOptions) { | ||
var url = this._buildUrlBase(originalUrl, fetchOptions.base); | ||
if (!queryParams) { | ||
return originalUrl; | ||
return url; | ||
} | ||
var hasQS = originalUrl.includes("?"); | ||
var hasQS = url.includes("?"); | ||
var appendChar = hasQS ? "&" : "?"; // @todo extract existing query params from string and include for stringify ? | ||
return originalUrl + appendChar + stringify(queryParams); | ||
return url + appendChar + stringify(queryParams); | ||
} | ||
@@ -159,3 +191,3 @@ }, { | ||
}); | ||
url = this._buildUrl(originalUrl, queryParams); | ||
url = this._buildUrl(originalUrl, queryParams, fetchOptions); | ||
request = new _request2.default(url, fetchOptions, originalUrl, queryParams); | ||
@@ -162,0 +194,0 @@ _context.next = 5; |
{ | ||
"name": "api-reach", | ||
"version": "0.0.1-alpha.1", | ||
"version": "0.0.1-alpha.2", | ||
"repository": "https://github.com/dzek69/api-reach.git", | ||
@@ -14,3 +14,3 @@ "author": "Jacek Nowacki @dzek69 <git-public@dzek.eu>", | ||
"prepack": "npm run transpile", | ||
"lint": "eslint src/**/*.js src/*.js", | ||
"lint": "eslint src/**/*.js src/*.js src/**/*.mjs src/*.mjs", | ||
"lint:fix": "npm run lint -- --fix" | ||
@@ -38,3 +38,4 @@ }, | ||
"light-isomorphic-fetch": "^1.0.0", | ||
"qs": "^6.6.0" | ||
"qs": "^6.6.0", | ||
"url-join": "^4.0.0" | ||
}, | ||
@@ -41,0 +42,0 @@ "peerDependencies": { |
@@ -19,2 +19,3 @@ # api-reach | ||
- cookie jar support | ||
- add files upload support | ||
@@ -21,0 +22,0 @@ - add binary support |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
167650
1892
38
1
5
28
+ Addedurl-join@^4.0.0
+ Addedurl-join@4.0.1(transitive)