Skip to content

Commit 0a91a9b

Browse files
Mikachu2333ccmywish
authored andcommitted
test
1 parent 5f77b80 commit 0a91a9b

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

lib/xy.h

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -912,26 +912,19 @@ xy_normalize_path (const char *path)
912912
{
913913
char *new = xy_str_strip (path); // 防止开发者多写了空白符
914914

915-
if (xy_on_windows)
915+
if (xy_str_start_with (new, "~"))
916916
{
917-
if (xy_str_start_with (new, "~/"))
918-
{
919-
// 或 %USERPROFILE%
920-
new = xy_strjoin (3, xy_os_home, "\\",
921-
xy_str_delete_prefix (new, "~/"));
922-
}
923-
new = xy_str_gsub (new, "/", "\\");
924-
}
925-
else
926-
{
927-
if (xy_str_start_with (new, "~/"))
928-
{
929-
new = xy_strjoin (3, xy_os_home, "/",
930-
xy_str_delete_prefix (new, "~/"));
931-
}
917+
new = xy_strjoin (3, xy_os_home, "/",
918+
xy_str_delete_prefix (new, "~"));
932919
}
933920

934-
return new;
921+
new = xy_str_gsub (new, "\\", "/");
922+
new = xy_str_gsub (new, "//", "/");
923+
924+
if (xy_on_windows)
925+
return xy_str_gsub (new, "/", "\\");
926+
else
927+
return new;
935928
}
936929

937930
static char *

0 commit comments

Comments
 (0)