feat: image upload + list root assets (wip)
This commit is contained in:
12
server/helpers/asset.js
Normal file
12
server/helpers/asset.js
Normal file
@@ -0,0 +1,12 @@
|
||||
const crypto = require('crypto')
|
||||
|
||||
/* global WIKI */
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Generate unique hash from page
|
||||
*/
|
||||
generateHash(assetPath) {
|
||||
return crypto.createHash('sha1').update(assetPath).digest('hex')
|
||||
}
|
||||
}
|
@@ -3,7 +3,6 @@ const _ = require('lodash')
|
||||
const crypto = require('crypto')
|
||||
|
||||
const localeSegmentRegex = /^[A-Z]{2}(-[A-Z]{2})?$/i
|
||||
const systemSegmentRegex = /^[A-Z]\//i
|
||||
|
||||
/* global WIKI */
|
||||
|
||||
@@ -67,8 +66,17 @@ module.exports = {
|
||||
*/
|
||||
isReservedPath(rawPath) {
|
||||
const firstSection = _.head(rawPath.split('/'))
|
||||
return _.some(WIKI.data.reservedPaths, p => {
|
||||
return p === firstSection || systemSegmentRegex.test(rawPath)
|
||||
})
|
||||
if (firstSection.length === 1) {
|
||||
return true
|
||||
} else if (localeSegmentRegex.test(firstSection)) {
|
||||
return true
|
||||
} else if (
|
||||
_.some(WIKI.data.reservedPaths, p => {
|
||||
return p === firstSection
|
||||
})) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user