From 0a91a9bdd5f6cd0c79f568b4b453cb2b905ee22a Mon Sep 17 00:00:00 2001 From: Mikachu2333 Date: Sun, 17 Aug 2025 19:28:37 +0800 Subject: [PATCH] test --- lib/xy.h | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/lib/xy.h b/lib/xy.h index 771489f..dd39274 100644 --- a/lib/xy.h +++ b/lib/xy.h @@ -912,26 +912,19 @@ xy_normalize_path (const char *path) { char *new = xy_str_strip (path); // 防止开发者多写了空白符 - if (xy_on_windows) + if (xy_str_start_with (new, "~")) { - if (xy_str_start_with (new, "~/")) - { - // 或 %USERPROFILE% - new = xy_strjoin (3, xy_os_home, "\\", - xy_str_delete_prefix (new, "~/")); - } - new = xy_str_gsub (new, "/", "\\"); - } - else - { - if (xy_str_start_with (new, "~/")) - { - new = xy_strjoin (3, xy_os_home, "/", - xy_str_delete_prefix (new, "~/")); - } + new = xy_strjoin (3, xy_os_home, "/", + xy_str_delete_prefix (new, "~")); } - return new; + new = xy_str_gsub (new, "\\", "/"); + new = xy_str_gsub (new, "//", "/"); + + if (xy_on_windows) + return xy_str_gsub (new, "/", "\\"); + else + return new; } static char *