FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Make wasm GIT_CORS_PROXY env var much more configurable by ianthomas23 · Pull Request #155 · QuantStack/git2cpp · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .cpp  (1) .json  (2) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
37 changes: 16 additions & 21 deletions src/wasm/stream.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -125,32 +125,27 @@ EM_JS(const char*, js_maybe_convert_url, (const char* url_str), {
let ret = url_js; // Default to returning original unconverted URL as new string.
if (GIT_CORS_PROXY)
{
// clang-format off
const GIT_CORS_PROXY_TYPE = env["GIT_CORS_PROXY_TYPE"] ?? "prefix";
// clang-format on
if (GIT_CORS_PROXY_TYPE == "prefix")
if (!GIT_CORS_PROXY.includes("{"))
{
ret = GIT_CORS_PROXY;
if (ret.at(-1) != '/')
{
ret += '/';
}
ret += url_js;
ret = GIT_CORS_PROXY + url_js;
}
else if (GIT_CORS_PROXY_TYPE == "insert")
else
{
ret = url.protocol + "/" + GIT_CORS_PROXY;
if (ret.at(-1) != '/')
ret = GIT_CORS_PROXY;
ret = ret.replace("{url}", url_js);
ret = ret.replace("{url:encode}", encodeURIComponent(url_js));
ret = ret.replace("{protocol}", url.protocol);
ret = ret.replace("{protocol:encode}", encodeURIComponent(url.protocol));
ret = ret.replace("{host}", url.host);
ret = ret.replace("{host:encode}", encodeURIComponent(url.host));
ret = ret.replace("{path}", url.pathname + url.search);
ret = ret.replace("{path:encode}", encodeURIComponent(url.pathname + url.search));
const api_key = env["GIT_CORS_PROXY_API_KEY"];
if (api_key)
{
ret += '/';
ret = ret.replace("{api_key}", api_key);
}
ret += url.host + url.pathname + url.search;
}
else
{
// clang-format off
console.warn(`Invalid GIT_CORS_PROXY_TYPE of '${GIT_CORS_PROXY_TYPE}'`);
// clang-format on
// Ignore any other use of curly braces.
}
}
return stringToNewUTF8(ret);
Expand Down
1 change: 0 additions & 1 deletion wasm/cockle-deploy/cockle-config-in.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"vi": "vim"
},
"environment": {
"GIT_CORS_PROXY": "https://corsproxy.io/?url=",
"GIT_AUTHOR_NAME": "Jane Doe",
"GIT_AUTHOR_EMAIL": "jane.doe@blabla.com",
"GIT_COMMITTER_NAME": "Jane Doe",
Expand Down
1 change: 0 additions & 1 deletion wasm/lite-deploy/cockle-config-in.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"vi": "vim"
},
"environment": {
"GIT_CORS_PROXY": "https://corsproxy.io/?url=",
"GIT_AUTHOR_NAME": "Jane Doe",
"GIT_AUTHOR_EMAIL": "jane.doe@blabla.com",
"GIT_COMMITTER_NAME": "Jane Doe",
Expand Down

Back | FazBrowse Home | New Git URL