Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

api-reach

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api-reach - npm Package Compare versions

Comparing version 0.0.1-alpha.1 to 0.0.1-alpha.2

12

CHANGELOG.md

@@ -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

42

dist/index.js

@@ -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;

7

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc