| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4153938 commit d181147
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -323,7 +323,7 @@ struct file_check { | |||
| 323 | 323 | bool failed = true; | |
| 324 | 324 | uv_file file = -1; | |
| 325 | 325 | }; | |
| 326 | - inline const struct file_check check_file(URL search, | ||
| 326 | + inline const struct file_check check_file(const URL& search, | ||
| 327 | 327 | bool close = false, | |
| 328 | 328 | bool allow_dir = false) { | |
| 329 | 329 | struct file_check ret; | |
@@ -349,7 +349,7 @@ inline const struct file_check check_file(URL search, | |||
| 349 | 349 | if (close) uv_fs_close(nullptr, &fs_req, fd, nullptr); | |
| 350 | 350 | return ret; | |
| 351 | 351 | } | |
| 352 | - URL resolve_extensions(URL search, bool check_exact = true) { | ||
| 352 | + URL resolve_extensions(const URL& search, bool check_exact = true) { | ||
| 353 | 353 | if (check_exact) { | |
| 354 | 354 | auto check = check_file(search, true); | |
| 355 | 355 | if (!check.failed) { | |
@@ -365,10 +365,10 @@ URL resolve_extensions(URL search, bool check_exact = true) { | |||
| 365 | 365 | } | |
| 366 | 366 | return URL(""); | |
| 367 | 367 | } | |
| 368 | - inline URL resolve_index(URL search) { | ||
| 368 | + inline URL resolve_index(const URL& search) { | ||
| 369 | 369 | return resolve_extensions(URL("index", &search), false); | |
| 370 | 370 | } | |
| 371 | - URL resolve_main(URL search) { | ||
| 371 | + URL resolve_main(const URL& search) { | ||
| 372 | 372 | URL pkg("package.json", &search); | |
| 373 | 373 | auto check = check_file(pkg); | |
| 374 | 374 | if (!check.failed) { | |
@@ -402,7 +402,7 @@ URL resolve_main(URL search) { | |||
| 402 | 402 | } | |
| 403 | 403 | return URL(""); | |
| 404 | 404 | } | |
| 405 | - URL resolve_module(std::string specifier, URL* base) { | ||
| 405 | + URL resolve_module(std::string specifier, const URL* base) { | ||
| 406 | 406 | URL parent(".", base); | |
| 407 | 407 | URL dir(""); | |
| 408 | 408 | do { | |
@@ -427,7 +427,7 @@ URL resolve_module(std::string specifier, URL* base) { | |||
| 427 | 427 | return URL(""); | |
| 428 | 428 | } | |
| 429 | 429 | ||
| 430 | - URL resolve_directory(URL search, bool read_pkg_json) { | ||
| 430 | + URL resolve_directory(const URL& search, bool read_pkg_json) { | ||
| 431 | 431 | if (read_pkg_json) { | |
| 432 | 432 | auto main = resolve_main(search); | |
| 433 | 433 | if (!(main.flags() & URL_FLAGS_FAILED)) return main; | |
@@ -438,7 +438,7 @@ URL resolve_directory(URL search, bool read_pkg_json) { | |||
| 438 | 438 | } // anonymous namespace | |
| 439 | 439 | ||
| 440 | 440 | ||
| 441 | - URL Resolve(std::string specifier, URL* base, bool read_pkg_json) { | ||
| 441 | + URL Resolve(std::string specifier, const URL* base, bool read_pkg_json) { | ||
| 442 | 442 | URL pure_url(specifier); | |
| 443 | 443 | if (!(pure_url.flags() & URL_FLAGS_FAILED)) { | |
| 444 | 444 | return pure_url; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,7 +13,7 @@ | |||
| 13 | 13 | namespace node { | |
| 14 | 14 | namespace loader { | |
| 15 | 15 | ||
| 16 | - node::url::URL Resolve(std::string specifier, node::url::URL* base, | ||
| 16 | + node::url::URL Resolve(std::string specifier, const node::url::URL* base, | ||
| 17 | 17 | bool read_pkg_json = false); | |
| 18 | 18 | ||
| 19 | 19 | class ModuleWrap : public BaseObject { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2081,7 +2081,7 @@ static void DomainToUnicode(const FunctionCallbackInfo<Value>& args) { | |||
| 2081 | 2081 | v8::NewStringType::kNormal).ToLocalChecked()); | |
| 2082 | 2082 | } | |
| 2083 | 2083 | ||
| 2084 | - std::string URL::ToFilePath() { | ||
| 2084 | + std::string URL::ToFilePath() const { | ||
| 2085 | 2085 | if (context_.scheme != "file:") { | |
| 2086 | 2086 | return ""; | |
| 2087 | 2087 | } | |
@@ -2102,7 +2102,7 @@ std::string URL::ToFilePath() { | |||
| 2102 | 2102 | } | |
| 2103 | 2103 | #endif | |
| 2104 | 2104 | std::string decoded_path; | |
| 2105 | - for (std::string& part : context_.path) { | ||
| 2105 | + for (const std::string& part : context_.path) { | ||
| 2106 | 2106 | std::string decoded; | |
| 2107 | 2107 | PercentDecode(part.c_str(), part.length(), &decoded); | |
| 2108 | 2108 | for (char& ch : decoded) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -154,7 +154,7 @@ class URL { | |||
| 154 | 154 | return context_.fragment; | |
| 155 | 155 | } | |
| 156 | 156 | ||
| 157 | - std::string path() { | ||
| 157 | + std::string path() const { | ||
| 158 | 158 | std::string ret; | |
| 159 | 159 | for (auto i = context_.path.begin(); i != context_.path.end(); i++) { | |
| 160 | 160 | ret += '/'; | |
@@ -165,7 +165,7 @@ class URL { | |||
| 165 | 165 | ||
| 166 | 166 | // Get the path of the file: URL in a format consumable by native file system | |
| 167 | 167 | // APIs. Returns an empty string if something went wrong. | |
| 168 | - std::string ToFilePath(); | ||
| 168 | + std::string ToFilePath() const; | ||
| 169 | 169 | ||
| 170 | 170 | const Local<Value> ToObject(Environment* env) const; | |
| 171 | 171 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments