Skip to content

frontend: Always reference resources relative to root #2070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 11, 2022

Conversation

erikarvstedt
Copy link
Contributor

In some cases, the frontend references resources via relative URLs.
Example: ./resources/bitcoin-logo.png, which resolves to /<lang>/resources/bitcoin-logo.png for non-default langs.
Convert all of these instances to root-relative URLs (/resources/bitcoin-logo.png).

With this fix, the language-invariant resource dir no longer has to be copied to each lang dir, which shrinks the frontend size by 55% (279M -> 124M).
Also, the nginx location config can be simplified.

Correctness

I've manually checked that relative resources access no longer happens by logging browser requests.

Also, searching the frontend for instances of string resource that are not preceded by "/, '/ or `/ shows no offending results.

grep -irP "$(cat <<'EOF'
(?<!["'`]/)resources
EOF
)" frontend

Still, these checks might be incomprehensive, so the frontend requires further real-world testing before switching off copying of resources.

This patch is deployed at https://mempool.nixbitcoin.org

@cla-bot cla-bot bot added the cla-signed label Jul 11, 2022
@erikarvstedt erikarvstedt force-pushed the fix-resources-access branch from db281b1 to a895306 Compare July 11, 2022 11:33
This patch was created by:
find ./frontend -type f -exec sed -i 's|\./resources|/resources|g' {} \;
@erikarvstedt erikarvstedt force-pushed the fix-resources-access branch from a895306 to 355e89c Compare July 11, 2022 11:33
@wiz wiz added this to the v2.5.0 milestone Jul 11, 2022
Copy link
Member

@wiz wiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested ACK @ v2.5.0-dev [73b2be0a]

@wiz
Copy link
Member

wiz commented Jul 11, 2022

@erikarvstedt in the future can you please sign all commits? thanks!

@wiz wiz merged commit 495cd26 into mempool:master Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy