Skip to content

Commit 0e2afcf

Browse files
authored
Merge pull request #52 from tinify/feature/remove-get-with-body
fix: removed GET with body from result() call and replaced with POST …
2 parents 60d59f9 + fad324b commit 0e2afcf

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

CHANGES.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
## 1.8.1
1+
## 1.8.2
2+
* Removed the `GET` with body HTTP call that was being made when obtaining the results of a compression and transforming at the same time. Replaced with `POST` in order to prepare for deprecation of `GET` with body interface from API.
3+
* Updated dependencies.
24

5+
## 1.8.1
36
* Set minimum node engine to v14 in package.json
47
* Update examples in README
58
* Test the code on node 24

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tinify",
3-
"version": "1.8.1",
3+
"version": "1.8.2",
44
"description": "Node.js client for the Tinify API. Tinify compresses your images intelligently. Read more at https://tinify.com.",
55
"keywords": [
66
"tinify",
@@ -50,8 +50,8 @@
5050
"mocha": "^2.2.5",
5151
"nock": "^13.2.9",
5252
"semver": "*",
53-
"tmp": "^0.0.26",
53+
"tmp": "^0.2.4",
5454
"tslint": "^5.10.0",
5555
"typescript": "^5.7.3"
5656
}
57-
}
57+
}

src/tinify/Source.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ export default class Source {
7777
result(): Result {
7878
const commands = this._commands
7979
const response = this._url.then(url => {
80-
return tinify.client.request("get", url, commands)
80+
if (Object.keys(commands).length > 0) {
81+
return tinify.client.request("post", url, commands)
82+
}
83+
return tinify.client.request("get", url)
8184
})
8285

8386
return new tinify.Result(

test/tinify-source-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ describe("Source", function() {
156156
.reply(201, {}, {location: "https://api.tinify.com/some/location"})
157157

158158
nock("https://api.tinify.com")
159-
.get("/some/location", '{"preserve":["copyright","location"]}')
159+
.post("/some/location", '{"preserve":["copyright","location"]}')
160160
.reply(200, "copyrighted file")
161161
})
162162

@@ -181,7 +181,7 @@ describe("Source", function() {
181181

182182
it("should include other options if set", function() {
183183
nock("https://api.tinify.com")
184-
.get("/some/location", '{"preserve":["copyright","location"],"resize":{"width":400}}')
184+
.post("/some/location", '{"preserve":["copyright","location"],"resize":{"width":400}}')
185185
.reply(200, "copyrighted resized file")
186186

187187
const data = tinify.Source.fromBuffer("png file").resize({width: 400}).preserve("copyright", "location").toBuffer()
@@ -198,7 +198,7 @@ describe("Source", function() {
198198
.reply(201, {}, {location: "https://api.tinify.com/some/location"})
199199

200200
nock("https://api.tinify.com")
201-
.get("/some/location", '{"resize":{"width":400}}')
201+
.post("/some/location", '{"resize":{"width":400}}')
202202
.reply(200, "small file")
203203
})
204204

0 commit comments

Comments
 (0)