feat: image upload + list root assets (wip)

This commit is contained in:
Nick
2019-05-13 01:15:27 -04:00
parent 89c07a716a
commit 6b886b6e3f
23 changed files with 526 additions and 171 deletions

12
server/helpers/asset.js Normal file
View 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')
}
}

View File

@@ -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
}
}
}