File tree Expand file tree Collapse file tree 1 file changed +22
-21
lines changed
Expand file tree Collapse file tree 1 file changed +22
-21
lines changed Original file line number Diff line number Diff line change @@ -59,36 +59,37 @@ type Param struct {
5959 ErrorLog string
6060}
6161
62+ func splitMapping (input string ) (k , v string , ok bool ) {
63+ sep , sepLen := utf8 .DecodeRuneInString (input )
64+ if sepLen == 0 {
65+ return
66+ }
67+ entry := input [sepLen :]
68+ if len (entry ) == 0 {
69+ return
70+ }
71+
72+ sepIndex := strings .IndexRune (entry , sep )
73+ if sepIndex <= 0 || sepIndex + sepLen == len (entry ) {
74+ return
75+ }
76+
77+ k = entry [:sepIndex ]
78+ v = entry [sepIndex + sepLen :]
79+ return k , v , true
80+ }
81+
6282func normalizePathMaps (inputs []string ) map [string ]string {
6383 maps := map [string ]string {}
6484
6585 for _ , input := range inputs {
66- sep , sepLen := utf8 .DecodeRuneInString (input )
67- if sepLen == 0 {
68- continue
69- }
70- input = input [sepLen :]
71- if len (input ) == 0 {
86+ urlPath , fsPath , ok := splitMapping (input )
87+ if ! ok {
7288 continue
7389 }
7490
75- sepIndex := strings .Index (input , string (sep ))
76- if sepIndex == - 1 {
77- continue
78- }
79-
80- urlPath := input [:sepIndex ]
81- if len (urlPath ) == 0 {
82- continue
83- }
8491 urlPath = util .CleanUrlPath (urlPath )
85-
86- fsPath := input [sepIndex + sepLen :]
87- if len (fsPath ) == 0 {
88- continue
89- }
9092 fsPath = path .Clean (fsPath )
91-
9293 maps [urlPath ] = fsPath
9394 }
9495
You can’t perform that action at this time.
0 commit comments