| 119 | }; |
| 120 | |
| 121 | const getImageFormat = body => { |
| 122 | const isPng = |
| 123 | body[0] === 137 && |
| 124 | body[1] === 80 && |
| 125 | body[2] === 78 && |
| 126 | body[3] === 71 && |
| 127 | body[4] === 13 && |
| 128 | body[5] === 10 && |
| 129 | body[6] === 26 && |
| 130 | body[7] === 10; |
| 131 | |
| 132 | const isJpg = body[0] === 255 && body[1] === 216 && body[2] === 255; |
| 133 | |
| 134 | let extension = ''; |
| 135 | if (isPng) { |
| 136 | extension = 'png'; |
| 137 | } else if (isJpg) { |
| 138 | extension = 'jpg'; |
| 139 | } else { |
| 140 | throw new Error('Not valid image extension'); |
| 141 | } |
| 142 | |
| 143 | return extension; |
| 144 | }; |
| 145 | |
| 146 | const resolveImageFromUrl = async src => { |
| 147 | const { uri, body, headers, method = 'GET' } = src; |
no outgoing calls
no test coverage detected