Skip to content
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

feat(frontend-canister): Add simple aliasing rules #2720

Merged
merged 40 commits into from
Nov 15, 2022

Conversation

sesi200
Copy link
Contributor

@sesi200 sesi200 commented Oct 26, 2022

Description

The asset canister now by default redirects any request to <asset> to <asset>.html.
This can be disabled by setting the field "redirect" to false in the canister settings in dfx.json.

Fixes SDK-789

How Has This Been Tested?

added e2e

Checklist:

  • The title of this PR complies with Conventional Commits.
  • I have edited the CHANGELOG accordingly.
  • I have made corresponding changes to the documentation.

@sesi200 sesi200 marked this pull request as ready for review October 26, 2022 10:03
@sesi200 sesi200 requested a review from a team as a code owner October 26, 2022 10:03

// path like /path/to/my/asset should also be valid for /path/to/my/asset.html
fn redirect(key: &Key) -> Option<Key> {
if !key.ends_with(".html") {

Choose a reason for hiding this comment

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

Is it intended that this should convert /path/to/my/asset.gz to /path/to/my/asset.gz.html ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not necessarily 'intended' but I think if someone creates a file /path/asset.gz.html and doesn't have a file /path/asset.gz I don't think it's unreasonable to redirect that

@sesi200 sesi200 changed the title feat(frontend-canister): Add simple redirects from <asset> to <asset>.html feat(frontend-canister): Add simple aliasing rules Oct 28, 2022
@sesi200 sesi200 marked this pull request as draft October 28, 2022 11:15
for (asset_name, asset) in state.assets.iter_mut() {
for enc in asset.encodings.values_mut() {
enc.certified = false;
let assets_keys: Vec<_> = state.assets.keys().map(|key| key.clone()).collect();
Copy link
Contributor Author

@sesi200 sesi200 Nov 9, 2022

Choose a reason for hiding this comment

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

This clone is not nice, but I can't find a better way to satisfy the borrow checker. Suggestions are very welcome

@sesi200 sesi200 marked this pull request as ready for review November 10, 2022 09:44
@sesi200 sesi200 merged commit 19e18d1 into master Nov 15, 2022
@sesi200 sesi200 deleted the SDK-789-asset-canister-path-aliases branch November 15, 2022 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants