Improve URL replacement strategy for frontend assets
- Enhanced rewrite_frontend_reference function to handle multiple URL encoding formats - Now replaces plain URLs, backslash-escaped URLs, and double-backslash-escaped URLs - Added https://ente.io -> BASE_URL replacement - Version bump to 0.3.0 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
"contactEmail": "contact@ente.io",
|
"contactEmail": "contact@ente.io",
|
||||||
"website": "https://ente.io",
|
"website": "https://ente.io",
|
||||||
"tagline": "Open source, end-to-end encrypted photo backup",
|
"tagline": "Open source, end-to-end encrypted photo backup",
|
||||||
"version": "0.2.2",
|
"version": "0.3.0",
|
||||||
"upstreamVersion": "git-main",
|
"upstreamVersion": "git-main",
|
||||||
"healthCheckPath": "/health",
|
"healthCheckPath": "/health",
|
||||||
"httpPort": 3080,
|
"httpPort": 3080,
|
||||||
|
|||||||
30
start.sh
30
start.sh
@@ -356,12 +356,37 @@ rewrite_frontend_reference() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Create escaped versions for different contexts
|
||||||
|
local search_escaped_slash="${search//\//\\/}"
|
||||||
|
local replace_escaped_slash="${replace//\//\\/}"
|
||||||
|
local search_json="${search//\//\\/}"
|
||||||
|
local replace_json="${replace//\//\\/}"
|
||||||
|
|
||||||
while IFS= read -r -d '' file; do
|
while IFS= read -r -d '' file; do
|
||||||
if LC_ALL=C grep -F -q "$search" "$file"; then
|
local file_changed=false
|
||||||
sed -i "s|$search|$replace|g" "$file"
|
|
||||||
|
# Check if file contains any variant of the search string
|
||||||
|
if LC_ALL=C grep -q -e "$search" -e "$search_escaped_slash" "$file" 2>/dev/null; then
|
||||||
|
# Replace plain URL
|
||||||
|
if sed -i "s|$search|$replace|g" "$file" 2>/dev/null; then
|
||||||
|
file_changed=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Replace backslash-escaped URL (common in JavaScript strings)
|
||||||
|
if sed -i "s|$search_escaped_slash|$replace_escaped_slash|g" "$file" 2>/dev/null; then
|
||||||
|
file_changed=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Replace double-backslash-escaped URL (common in JSON)
|
||||||
|
if sed -i "s|${search//\//\\\\/}|${replace//\//\\\\/}|g" "$file" 2>/dev/null; then
|
||||||
|
file_changed=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$file_changed" = true ]; then
|
||||||
chown cloudron:cloudron "$file"
|
chown cloudron:cloudron "$file"
|
||||||
count=$((count + 1))
|
count=$((count + 1))
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
done < <(find "$WEB_RUNTIME_DIR" -type f \( -name "*.js" -o -name "*.json" -o -name "*.html" -o -name "*.css" -o -name "*.txt" \) -print0)
|
done < <(find "$WEB_RUNTIME_DIR" -type f \( -name "*.js" -o -name "*.json" -o -name "*.html" -o -name "*.css" -o -name "*.txt" \) -print0)
|
||||||
|
|
||||||
if [ "$count" -gt 0 ]; then
|
if [ "$count" -gt 0 ]; then
|
||||||
@@ -381,6 +406,7 @@ if [ -d "$WEB_RUNTIME_DIR" ]; then
|
|||||||
"https://web.ente.io|$BASE_URL/photos"
|
"https://web.ente.io|$BASE_URL/photos"
|
||||||
"https://albums.ente.io|$BASE_URL/albums"
|
"https://albums.ente.io|$BASE_URL/albums"
|
||||||
"https://family.ente.io|$BASE_URL/family"
|
"https://family.ente.io|$BASE_URL/family"
|
||||||
|
"https://ente.io|$BASE_URL"
|
||||||
)
|
)
|
||||||
OLD_IFS="$IFS"
|
OLD_IFS="$IFS"
|
||||||
for entry in "${FRONTEND_REPLACEMENTS[@]}"; do
|
for entry in "${FRONTEND_REPLACEMENTS[@]}"; do
|
||||||
|
|||||||
Reference in New Issue
Block a user