Ver Fonte

Fix upstream issue #4

Mike L há 1 semana atrás
pai
commit
e87b008c07
2 ficheiros alterados com 6 adições e 5 exclusões
  1. 1 1
      package.json
  2. 5 4
      public/javascripts/view.js

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "naiveboom",
-  "version": "2.1.2",
+  "version": "2.1.3",
   "license": "MIT License",
   "private": true,
   "scripts": {

+ 5 - 4
public/javascripts/view.js

@@ -1,10 +1,13 @@
+var cleanURL = location.origin + location.pathname
+var origText
+
 function cacheDataURLFrom(text, toCache) {
 	var urlMap = {};
 	var attachmentCount = 0;
 	var test = /\[(.*?)\]\((data:.*?)\)/g;
 	var newText = text.replace(test, function (_, label, dataURL) {
 		fileName = encodeURIComponent(label.split(/[\\/]/).pop());
-		var fakeURL = location.href + '/' + ++attachmentCount +'/' + fileName;
+		var fakeURL = cleanURL + '/' + ++attachmentCount +'/' + fileName;
 		urlMap[fakeURL] = dataURL;
 		return '[' + label + '](' + fakeURL + ')';
 	});
@@ -21,8 +24,6 @@ function cacheDataURLFrom(text, toCache) {
 
 Vue.component('vue-easymde', VueEasyMDE.VueEasyMDE)
 
-var origText
-
 // 查看消息需要用到的JS
 app = new Vue({
 	el: '#app',
@@ -51,7 +52,7 @@ app = new Vue({
 	},
 	mounted: function() {
 		// 从URL获取GUID,然后透过POST获取消息
-		var guid = reg_guid.exec(location.href)[0];
+		var guid = reg_guid.exec(cleanURL)[0];
 		navigator.serviceWorker.register('./sw.js').then(function () {
 			return navigator.serviceWorker.ready;
 		}).then(function() {