Skip to content

Commit

Permalink
[12_1] Fix file_url with env provided
Browse files Browse the repository at this point in the history
  • Loading branch information
da-liii authored Oct 11, 2023
1 parent c417309 commit d8b3de4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions System/Classes/file_url.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
#include "url.hpp"

file_url::file_url (string name)
: url (url_root ("file") * url_get_name (name)) {}
: url (url_root ("file") * url_get_name (name, URL_SYSTEM)) {}

file_url::file_url (const char* name)
: url (url_root ("file") * url_get_name (string (name))) {}
: url (url_root ("file") * url_get_name (string (name), URL_SYSTEM)) {}

string
file_url::concretize () {
Expand Down
9 changes: 9 additions & 0 deletions tests/System/Classes/url_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ url ustc_edu = url_system ("https://ustc.edu.cn");
url texmacs_org = url_system ("http://texmacs.org");
url none_url = url_none ();
url file_root = url_root ("file");
url file_tmp = url_system ("file:///tmp");
url ftp_root = url_root ("ftp");
url wsl_ubuntu = url_system ("\\\\wsl.localhost\\Ubuntu");
url unix_root = url_system ("/");
Expand All @@ -36,6 +37,7 @@ TEST_CASE ("label of url") {
string_eq (unix_tmp_a.label (), "concat");
}
#endif
string_eq (file_tmp.label (), "concat");
string_eq (abc_url.label (), "");
}

Expand All @@ -55,6 +57,7 @@ TEST_CASE ("protocol of url") {
string_eq (get_root (ustc_edu), "https");
string_eq (get_root (texmacs_org), "http");
string_eq (get_root (file_root), "file");
string_eq (get_root (file_tmp), "file");
string_eq (get_root (ftp_root), "ftp");
#if defined(OS_MINGW) || defined(OS_WIN)
string_eq (get_root (wsl_ubuntu), "default");
Expand Down Expand Up @@ -130,6 +133,12 @@ TEST_CASE ("suffix") {
}

TEST_CASE ("as_string") {
set_env ("TEST_PWD", as_string (url_pwd ()));
url file_env_lua= url_system ("file:///$TEST_PWD/xmake.lua");
string_eq (as_string (file_env_lua), as_string (url_pwd () * "xmake.lua"));
url local_env_lua= url_system ("local:$TEST_PWD/xmake.lua");
string_eq (as_string (local_env_lua), as_string (url_pwd () * "xmake.lua"));

url dirs= url ("Data") | url ("Kernel") | url ("Plugins");
string_eq (as_string (dirs), string ("Data") * URL_SEPARATOR * "Kernel" *
URL_SEPARATOR * "Plugins");
Expand Down

0 comments on commit d8b3de4

Please sign in to comment.