summaryrefslogtreecommitdiff
path: root/public/js/history.js
diff options
context:
space:
mode:
authorChristoph (Sheogorath) Kern2018-03-18 15:13:06 +0100
committerGitHub2018-03-18 15:13:06 +0100
commitf6df2deb8439dda4576ee70691c98c1ab53c965d (patch)
tree6a56c539e86058cf89a50636b451167fc3a75f83 /public/js/history.js
parent6b30f662725b54d9c0ef3954fdb5a463da697cc2 (diff)
parent8bfe51940f2eff035394b7713cbbce5b9b446842 (diff)
Merge pull request #743 from hackmdio/fix-to-use-url-safe-base64
Fix to use url-safe base64 in note url
Diffstat (limited to 'public/js/history.js')
-rw-r--r--public/js/history.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/public/js/history.js b/public/js/history.js
index e14b80d8..71322818 100644
--- a/public/js/history.js
+++ b/public/js/history.js
@@ -3,6 +3,12 @@
import store from 'store'
import S from 'string'
+import LZString from 'lz-string'
+
+import {
+ checkNoteIdValid,
+ encodeNoteId
+} from './utils'
import {
checkIfAuth
@@ -291,6 +297,15 @@ function parseToHistory (list, notehistory, callback) {
else if (!list || !notehistory) callback(list, notehistory)
else if (notehistory && notehistory.length > 0) {
for (let i = 0; i < notehistory.length; i++) {
+ // migrate LZString encoded id to base64url encoded id
+ try {
+ let id = LZString.decompressFromBase64(notehistory[i].id)
+ if (id && checkNoteIdValid(id)) {
+ notehistory[i].id = encodeNoteId(id)
+ }
+ } catch (err) {
+ console.error(err)
+ }
// parse time to timestamp and fromNow
const timestamp = (typeof notehistory[i].time === 'number' ? moment(notehistory[i].time) : moment(notehistory[i].time, 'MMMM Do YYYY, h:mm:ss a'))
notehistory[i].timestamp = timestamp.valueOf()