Skip to content

Commit 6390aff

Browse files
committed
fix(polyfill): URL
1 parent cd242a3 commit 6390aff

File tree

1 file changed

+6
-2
lines changed
  • packages/canvas-polyfill

1 file changed

+6
-2
lines changed

packages/canvas-polyfill/URL.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@ import { knownFolders, File as NSFile, isIOS, path } from '@nativescript/core';
33
export class URL {
44
public static createObjectURL(object: any): string {
55
if (object instanceof Blob || object instanceof File) {
6-
const filePath = path.join(knownFolders.temp().path, this.getUUID() + '.js');
6+
let filePath = path.join(knownFolders.documents().path, this.getUUID());
7+
if (object && object.type === 'text/javascript') {
8+
filePath = filePath + '.js';
9+
}
710
const buf = (Blob as any).InternalAccessor.getBuffer(object);
811
if (isIOS) {
912
NSFile.fromPath(filePath).writeSync(NSData.dataWithData(buf));
1013
} else {
1114
try {
12-
const fos = new java.io.FileOutputStream(new java.io.File(filePath));
15+
const file = new java.io.File(filePath);
16+
const fos = new java.io.FileOutputStream(file);
1317
fos.write(Array.from(buf) as any);
1418
fos.flush();
1519
fos.close();

0 commit comments

Comments
 (0)