refactor: obj name mapping and internal path processing (#2733)
* refactor:Prepare to remove the get interface * feat:add obj Unwarp interface * refactor:obj name mapping and program internal path processing * chore: fix typo * feat: unwrap get * fix: no use op.Get to get parent id * fix: set the path uniformly Co-authored-by: Noah Hsu <i@nn.ci>
This commit is contained in:
@ -44,7 +44,7 @@ func CreateMeta(c *gin.Context) {
|
||||
common.ErrorStrResp(c, fmt.Sprintf("%s is illegal: %s", r, err.Error()), 400)
|
||||
return
|
||||
}
|
||||
req.Path = utils.StandardizePath(req.Path)
|
||||
req.Path = utils.FixAndCleanPath(req.Path)
|
||||
if err := db.CreateMeta(&req); err != nil {
|
||||
common.ErrorResp(c, err, 500, true)
|
||||
} else {
|
||||
@ -63,7 +63,7 @@ func UpdateMeta(c *gin.Context) {
|
||||
common.ErrorStrResp(c, fmt.Sprintf("%s is illegal: %s", r, err.Error()), 400)
|
||||
return
|
||||
}
|
||||
req.Path = utils.StandardizePath(req.Path)
|
||||
req.Path = utils.FixAndCleanPath(req.Path)
|
||||
if err := db.UpdateMeta(&req); err != nil {
|
||||
common.ErrorResp(c, err, 500, true)
|
||||
} else {
|
||||
|
@ -42,7 +42,7 @@ func Down(c *gin.Context) {
|
||||
// TODO: implement
|
||||
// path maybe contains # ? etc.
|
||||
func parsePath(path string) string {
|
||||
return utils.StandardizePath(path)
|
||||
return utils.FixAndCleanPath(path)
|
||||
}
|
||||
|
||||
func needSign(meta *model.Meta, path string) bool {
|
||||
|
@ -31,7 +31,7 @@ func getSiteConfig() SiteConfig {
|
||||
siteConfig.BasePath = setting.GetStr(conf.BasePath)
|
||||
}
|
||||
if siteConfig.BasePath != "" {
|
||||
siteConfig.BasePath = utils.StandardizePath(siteConfig.BasePath)
|
||||
siteConfig.BasePath = utils.FixAndCleanPath(siteConfig.BasePath)
|
||||
}
|
||||
if siteConfig.Cdn == "" {
|
||||
siteConfig.Cdn = siteConfig.BasePath
|
||||
|
Reference in New Issue
Block a user