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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 16 additions & 21 deletions src/wasm/stream.cpp
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
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
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