@waline/vercel 1.13.0 → 1.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/controller/db.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
const fs = require('fs
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const util = require('util');
|
|
2
3
|
const BaseRest = require('./rest');
|
|
3
4
|
|
|
5
|
+
const readFileAsync = util.promisify(fs.readFile);
|
|
4
6
|
module.exports = class extends BaseRest {
|
|
5
7
|
async getAction() {
|
|
6
8
|
const exportData = {
|
|
@@ -17,7 +19,10 @@ module.exports = class extends BaseRest {
|
|
|
17
19
|
|
|
18
20
|
for (let i = 0; i < exportData.tables.length; i++) {
|
|
19
21
|
const tableName = exportData.tables[i];
|
|
20
|
-
const model = this.
|
|
22
|
+
const model = this.service(
|
|
23
|
+
`storage/${this.config('storage')}`,
|
|
24
|
+
tableName
|
|
25
|
+
);
|
|
21
26
|
const data = await model.select({});
|
|
22
27
|
exportData.data[tableName] = data;
|
|
23
28
|
}
|
|
@@ -28,7 +33,7 @@ module.exports = class extends BaseRest {
|
|
|
28
33
|
async postAction() {
|
|
29
34
|
const file = this.file('file');
|
|
30
35
|
try {
|
|
31
|
-
const jsonText = await
|
|
36
|
+
const jsonText = await readFileAsync(file.path, 'utf-8');
|
|
32
37
|
const importData = JSON.parse(jsonText);
|
|
33
38
|
if (!importData || importData.type !== 'waline') {
|
|
34
39
|
return this.fail('import data format not support!');
|
|
@@ -9,7 +9,7 @@ const DOMPurify = createDOMPurify(new JSDOM('').window);
|
|
|
9
9
|
*/
|
|
10
10
|
DOMPurify.addHook('afterSanitizeAttributes', function (node) {
|
|
11
11
|
// set all elements owning target to target=_blank
|
|
12
|
-
if ('target' in node) {
|
|
12
|
+
if ('target' in node && node.href && !node.href.startsWith('about:blank#')) {
|
|
13
13
|
node.setAttribute('target', '_blank');
|
|
14
14
|
node.setAttribute('rel', 'noreferrer noopener');
|
|
15
15
|
}
|