Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit d7f89a6

Browse files
committed
fix(Resources): URLs should not contain trailing slashes
APIv4 URLs do not have trailing slashes. Unfortunately, `url-join` pushes arguments onto an array and joins them with '/' without first ensuring removing empty segments. Since we only ever join two segments ourselves, and we control both segments, we don't need this dependency or it's normalization.
1 parent 63f4d8c commit d7f89a6

5 files changed

Lines changed: 3 additions & 11 deletions

File tree

lib/Client.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22
var prototypal = require('es-class');
3-
var join = require('url-join');
43
var pkg = require('../package.json');
54
var Getter = require('./Getter');
65

@@ -32,7 +31,7 @@ module.exports = prototypal({
3231
this.getter = new Getter(options);
3332
},
3433
request: function (requestMethod, requestPath, data, opts) {
35-
var uri = join('https://api.cloudflare.com/client/v4/', requestPath);
34+
var uri = 'https://api.cloudflare.com/client/v4/' + requestPath;
3635

3736
var options = {
3837
json: true,

lib/Resource.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22
var prototypal = require('es-class');
3-
var join = require('url-join');
43
var method = require('./method');
54

65
var BASIC_METHODS = {
@@ -45,7 +44,7 @@ module.exports = prototypal({
4544
}
4645
},
4746
createFullPath: function (methodPath) {
48-
return join(this.path, methodPath);
47+
return (methodPath && [this.path, methodPath].join('/')) || this.path;
4948
},
5049
path: '',
5150
hasBrokenPatch: false

package-lock.json

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"es-class": "^2.1.1",
1212
"got": "^6.3.0",
1313
"object-assign": "^4.1.0",
14-
"url-join": "^1.1.0",
1514
"url-pattern": "^1.0.3"
1615
},
1716
"devDependencies": {

test/Resource.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('Resource', function () {
3737

3838
var path = subject.createFullPath();
3939

40-
assert.equal(path, '/');
40+
assert.equal(path, '');
4141
});
4242

4343
it('joins method path with resource path', function () {

0 commit comments

Comments
 (0)