@@ -87,7 +87,7 @@ sul =ko:section(TypedSection, "clash", translate("Upload Config"))
8787sul .anonymous = true
8888sul .addremove = false
8989o = sul :option (FileUpload , " " )
90- o .description = translate (" NB: Only upload file with name .yaml.It recommended to rename each upload file name to avoid overwrite" )
90+ -- o.description = translate("NB: Only upload file with name .yaml.It recommended to rename each upload file name to avoid overwrite")
9191o .title = translate (" " )
9292o .template = " clash/clash_upload"
9393um = sul :option (DummyValue , " " , nil )
@@ -96,6 +96,7 @@ um.template = "clash/clash_dvalue"
9696local dir , fd
9797dir = " /usr/share/clash/config/upload/"
9898http .setfilehandler (
99+
99100 function (meta , chunk , eof )
100101 if not fd then
101102 if not meta then return end
@@ -113,9 +114,15 @@ http.setfilehandler(
113114 if eof and fd then
114115 fd :close ()
115116 fd = nil
117+ local e = string.lower (string.sub (meta .file ,- 4 ,- 1 ))
118+ local yml2 = string.lower (string.sub (meta .file ,0 ,- 5 ))
119+ if e == ' .yml' then
116120 local yml = string.lower (string.sub (meta .file ,0 ,- 5 ))
117121 local c = fs .rename (dir .. meta .file ," /usr/share/clash/config/upload/" .. yml .. " .yaml" )
118122 um .value = translate (" File saved to" ) .. ' "/usr/share/clash/config/upload/' .. yml .. ' .yaml"'
123+ else
124+ um .value = translate (" File saved to" ) .. ' "/usr/share/clash/config/upload/' .. yml2 .. ' yaml"'
125+ end
119126
120127 end
121128 end
0 commit comments