From bd692e1c979c61d750d397c2ea77e7d9a959d9eb Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Wed, 19 Apr 2023 21:27:15 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20passing=20multiple=20`=E2=80=94header`=20?= =?UTF-8?q?flags?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #43 --- .github/workflows/main.yml | 1 - cli.js | 6 ++++-- package.json | 1 - test.js.md | 1 - test.js.snap | Bin 1171 -> 1152 bytes 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dc47f7c..928fff3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,7 +12,6 @@ jobs: node-version: - 18 - 16 - - 14 steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 diff --git a/cli.js b/cli.js index 7d54690..07d3cdc 100755 --- a/cli.js +++ b/cli.js @@ -2,7 +2,6 @@ import process from 'node:process'; import meow from 'meow'; import captureWebsite from 'capture-website'; -import arrify from 'arrify'; import splitOnFirst from 'split-on-first'; import getStdin from 'get-stdin'; @@ -166,6 +165,7 @@ const cli = meow(` }, header: { type: 'string', + isMultiple: true, }, userAgent: { type: 'string', @@ -222,11 +222,13 @@ if (options.clip) { } options.headers = {}; -for (const header of arrify(options.header)) { +for (const header of options.header) { const [key, value] = header.split(':'); options.headers[key.trim()] = value.trim(); } +delete options.header; + if (options.authentication) { const [username, password] = splitOnFirst(options.authentication, ':'); options.authentication = {username, password}; diff --git a/package.json b/package.json index 0856772..ca5d1c2 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,6 @@ "jpg" ], "dependencies": { - "arrify": "^3.0.0", "capture-website": "^3.0.0", "get-stdin": "^9.0.0", "meow": "^10.1.3", diff --git a/test.js.md b/test.js.md index 11a84ee..ea5ce42 100644 --- a/test.js.md +++ b/test.js.md @@ -32,7 +32,6 @@ Generated by [AVA](https://avajs.dev). element: '.main-content', emulateDevice: 'iPhone X', fullPage: false, - header: 'x-powered-by: capture-website-cli', headers: { 'x-powered-by': 'capture-website-cli', }, diff --git a/test.js.snap b/test.js.snap index 7f4703969d7b90dbed444681b03bcba67bb7ef47..7ec122bd55b39b52bc6aa0e85ab39982909734e6 100644 GIT binary patch literal 1152 zcmV-`1b_QMRzV}@kkE<(LA2SVkx-*VkqD4fAVrCk zO0-fhv%6#O#Irlg%xoO1ry}6O0U?zmhayf${E$E#5C={ik>Ca=eh5*)iGP6h?b@-| zW4D$*c|GrYZ{GX%%^Tls`&7Zesj45Ff`D!qp|*B$jj?JAF~w$p&&-to~72bpj!}j4E^EkjU=72 z(&0-}h4rXpt+GT>GxNt7)FTtZ4<$V9<)>q|9_N{Qot%)PK(bWtCb@(Uk$?Uec&gx) z3w*bfN`sRu38I6vcman0InIJ;^kkU5E2#MmW>MMsl#V=Dk=X@@pxPrlc{%8H+wyiV6s)dnC|84*St6LfkLc zGSJHOZNakO{F*RMp?x7HgVXk;GY(Qyx<9RlqghPFP!Jm*8fIJf(^0opk5k(5OpP){ zdpsH;^+cAb- zWpe1%arJ$md?v3>T`YPAZ|J`j%TMy%>otoMNO zff1`_#HxM@gf9U<0{#Iwb4FZeD(=%jdETVeO`3fbDEokS0H4fFrZH!h^g9s#Hc0c6 zqzT)(N7xo7Y>oU1GzMHsl`wbdia@Q}r2Z46i*Di0kYgabcH#XPS+^hT7 zwuP*s=9`zNBq7}GHXQxs36ij!Y$l22P0`BH`Sjm6p zLFcr6HUyq9Rg+^)ryMOU(y?qaimK=58V1jJQUlL2b6<|MPSxh>s$xk9@(CGb$_qri znvYMYy3IKCj@8f){^;+)D}oE@ZoA8%`SNU4 SYb@?~BzypJlY=5I3IG6MoGdp0 literal 1171 zcmV;E1Z?|3RzV#3K>Zu$l$4dMQlmkM*g#$u@0|z7yJs}m4K%98H{H?^+KQ=|Bq|hIojeEvqRG4Us}{0R z_J?cu!k6&>YryXS3nSzLt^?i!+yQ(F_zLhVpi)9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