screenshotone-api-sdk 1.0.30 → 1.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -192,7 +192,12 @@ class TakeOptions {
192
192
  }
193
193
  put(key, ...values) {
194
194
  for (const value of values) {
195
- this.query.append(key, value);
195
+ if (values.length == 1) {
196
+ this.query.set(key, value);
197
+ }
198
+ else {
199
+ this.query.append(key, value);
200
+ }
196
201
  }
197
202
  }
198
203
  ;
@@ -611,7 +616,12 @@ class AnimateOptions {
611
616
  }
612
617
  put(key, ...values) {
613
618
  for (const value of values) {
614
- this.query.append(key, value);
619
+ if (values.length == 1) {
620
+ this.query.set(key, value);
621
+ }
622
+ else {
623
+ this.query.append(key, value);
624
+ }
615
625
  }
616
626
  }
617
627
  ;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "screenshotone-api-sdk",
3
3
  "homepage": "https://screenshotone.com",
4
- "version": "1.0.30",
4
+ "version": "1.0.32",
5
5
  "description": "Use ScreenshotOne.com API to generate screenshots of any website.",
6
6
  "repository": {
7
7
  "type": "git",
@@ -42,6 +42,7 @@
42
42
  "cross-fetch": "^3.1.5"
43
43
  },
44
44
  "scripts": {
45
+ "test": "jest",
45
46
  "build": "tsc",
46
47
  "prepare": "npm run build"
47
48
  }
package/src/main.ts CHANGED
@@ -205,10 +205,15 @@ export class TakeOptions {
205
205
 
206
206
  private put(key: string, ...values: string[]) {
207
207
  for (const value of values) {
208
- this.query.append(key, value);
208
+ if (values.length == 1) {
209
+ this.query.set(key, value);
210
+ } else {
211
+ this.query.append(key, value);
212
+ }
209
213
  }
210
214
  };
211
215
 
216
+
212
217
  /**
213
218
  * Selector is a CSS-like selector of the element to take a screenshot of.
214
219
  */
@@ -734,7 +739,11 @@ export class AnimateOptions {
734
739
 
735
740
  private put(key: string, ...values: string[]) {
736
741
  for (const value of values) {
737
- this.query.append(key, value);
742
+ if (values.length == 1) {
743
+ this.query.set(key, value);
744
+ } else {
745
+ this.query.append(key, value);
746
+ }
738
747
  }
739
748
  };
740
749
 
@@ -1,4 +1,4 @@
1
- import { TakeOptions, Client } from '../src/main';
1
+ import { TakeOptions, Client, AnimateOptions } from '../src/main';
2
2
 
3
3
  describe('testing client', () => {
4
4
  const client = new Client('RcLsdM6uhIN6gw', 'MW2vfkkgLTzGGw');
@@ -17,5 +17,18 @@ describe('testing client', () => {
17
17
  .userAgent('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36');
18
18
 
19
19
  expect(client.generateTakeURL(options)).toBe('https://api.screenshotone.com/take?url=https%3A%2F%2Fexample.com&block_ads=true&full_page=true&user_agent=Mozilla%2F5.0+%28X11%3B+Linux+x86_64%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Chrome%2F51.0.2704.103+Safari%2F537.36&access_key=RcLsdM6uhIN6gw&signature=ea217db7d746c8bf9b710257d62ef09670b003137d239ee4c81eae3645b4a901');
20
- });
20
+ });
21
+
22
+ test('setting an option twice doesn`t convert it to an array parameter (TakeOptions)', () => {
23
+ const options = TakeOptions.url("https://example.com").blockAds(true).blockAds(true);
24
+
25
+ expect(options.toQuery().getAll("block_ads").length).toBe(1);
26
+ });
27
+
28
+ test('setting an option twice doesn`t convert it to an array parameter (AnimateOptions)', () => {
29
+ const options = AnimateOptions.url("https://example.com").blockAds(true).blockAds(true);
30
+
31
+ expect(options.toQuery().getAll("block_ads").length).toBe(1);
32
+ });
33
+
21
34
  });