This repository was archived by the owner on Jul 26, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +2
-8
lines changed Expand file tree Collapse file tree 2 files changed +2
-8
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { encodeDataURL } from '../../save/encodeDataURL.js';
2
2
import { fetchURL } from '../fetchURL.js' ;
3
3
4
4
describe ( 'testing fetchURL' , ( ) => {
5
- test ( 'basic test 1 ' , async ( ) => {
5
+ test ( 'decodes image from data URL ' , async ( ) => {
6
6
const image = await fetchURL (
7
7
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAAAAACoBHk5AAAAFklEQVR4XmNggID///+DSCCEskHM/wCAnQr2TY5mOAAAAABJRU5ErkJggg==' ,
8
8
) ;
@@ -21,10 +21,4 @@ describe('testing fetchURL', () => {
21
21
const result = encodeDataURL ( image ) ;
22
22
expect ( result ) . toEqual ( dataURL ) ;
23
23
} ) ;
24
- test ( 'decode from an image url' , async ( ) => {
25
- const image = await fetchURL ( 'https://picsum.photos/id/237/150/200' ) ;
26
- expect ( image . width ) . toEqual ( 150 ) ;
27
- expect ( image . height ) . toEqual ( 200 ) ;
28
- expect ( image . bitDepth ) . toEqual ( 8 ) ;
29
- } ) ;
30
24
} ) ;
Original file line number Diff line number Diff line change @@ -8,6 +8,6 @@ import { decode } from './decode.js';
8
8
export async function fetchURL ( dataUrl : string ) {
9
9
const response = await fetch ( dataUrl ) ;
10
10
const arrayBuffer = await response . arrayBuffer ( ) ;
11
- const image = decode ( new Uint8Array ( arrayBuffer ) ) ;
11
+ const image = decode ( new DataView ( arrayBuffer ) ) ;
12
12
return image ;
13
13
}
You can’t perform that action at this time.
0 commit comments