Skip to content

Commit

Permalink
Use arrayBuffer instead of text for profileURL (#179)
Browse files Browse the repository at this point in the history
When using #profileURL, some binary characters cannot be read if we use `fetch text`. So I changed that to use `arrayBuffer`.

Now we can read pprof protobuf files and normal JSON files instead of only text files.
  • Loading branch information
f-hj authored and jlfwong committed Oct 13, 2018
1 parent 0fe0c45 commit 86f4ba6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/views/application.tsx
Expand Up @@ -33,6 +33,13 @@ async function importProfilesFromBase64(
return (await importModule).importProfileGroupFromBase64(fileName, contents)
}

async function importProfilesFromArrayBuffer(
fileName: string,
contents: ArrayBuffer,
): Promise<ProfileGroup | null> {
return (await importModule).importProfilesFromArrayBuffer(fileName, contents)
}

async function importProfilesFromFile(file: File): Promise<ProfileGroup | null> {
return (await importModule).importProfilesFromFile(file)
}
Expand Down Expand Up @@ -512,7 +519,7 @@ export class Application extends StatelessComponent<ApplicationProps> {
if (filename.includes('/')) {
filename = filename.slice(filename.lastIndexOf('/') + 1)
}
return await importProfilesFromText(filename, await response.text())
return await importProfilesFromArrayBuffer(filename, await response.arrayBuffer())
})
} else if (this.props.hashParams.localProfilePath) {
// There isn't good cross-browser support for XHR of local files, even from
Expand Down

0 comments on commit 86f4ba6

Please sign in to comment.