Try to compare the diff of encoding/xml.

This commit is contained in:
zicla
2019-04-25 16:33:04 +08:00
parent 0879eb2f95
commit b076a43f30
2 changed files with 13 additions and 51 deletions

View File

@ -4,6 +4,7 @@ import (
"encoding/xml"
"fmt"
"net/http"
"path"
"strconv"
"tank/rest/dav"
)
@ -17,6 +18,17 @@ type LiveProp struct {
dir bool
}
// SlashClean is equivalent to but slightly more efficient than
// path.Clean("/" + name).
func SlashClean(name string) string {
if name == "" || name[0] != '/' {
name = "/" + name
}
return path.Clean(name)
}
//所有的动态属性定义及其值的获取方式
var LivePropMap = map[xml.Name]LiveProp{
{Space: "DAV:", Local: "resourcetype"}: {
@ -31,7 +43,7 @@ var LivePropMap = map[xml.Name]LiveProp{
},
{Space: "DAV:", Local: "displayname"}: {
findFn: func(user *User, matter *Matter) string {
if dav.SlashClean(matter.Name) == "/" {
if SlashClean(matter.Name) == "/" {
return ""
} else {
return dav.EscapeXML(matter.Name)