Skip to content

Commit 05dbda0

Browse files
authored
use blob url to replace data url (#817)
1 parent c57d05f commit 05dbda0

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/components/Popup/BackupPage.vue

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@
4646
</template>
4747
<script lang="ts">
4848
import Vue from "vue";
49-
import { mapState } from "vuex";
50-
import { Encryption } from "../../models/encryption";
51-
import { EntryStorage } from "../../models/storage";
52-
import * as CryptoJS from "crypto-js";
5349
5450
export default Vue.extend({
5551
data: function () {
@@ -152,10 +148,7 @@ function getBackupFile(
152148
let json = JSON.stringify(entryData, null, 2);
153149
// for windows notepad
154150
json = json.replace(/\n/g, "\r\n");
155-
const base64Data = CryptoJS.enc.Base64.stringify(
156-
CryptoJS.enc.Utf8.parse(json)
157-
);
158-
return `data:application/octet-stream;base64,${base64Data}`;
151+
return downloadFileUrlBuilder(json);
159152
}
160153
161154
function getOneLineOtpBackupFile(entryData: { [hash: string]: OTPStorage }) {
@@ -198,10 +191,12 @@ function getOneLineOtpBackupFile(entryData: { [hash: string]: OTPStorage }) {
198191
otpAuthLines.push(otpAuthLine);
199192
}
200193
201-
const base64Data = CryptoJS.enc.Base64.stringify(
202-
CryptoJS.enc.Utf8.parse(otpAuthLines.join("\r\n"))
203-
);
204-
return `data:application/octet-stream;base64,${base64Data}`;
194+
return downloadFileUrlBuilder(otpAuthLines.join("\r\n"));
195+
}
196+
197+
function downloadFileUrlBuilder(content: string) {
198+
const blob = new Blob([content], { type: "application/octet-stream" });
199+
return URL.createObjectURL(blob);
205200
}
206201
207202
function removeUnsafeData(data: string) {

0 commit comments

Comments
 (0)