Skip to content
This repository was archived by the owner on Feb 9, 2024. It is now read-only.

Conversation

@exvuma
Copy link
Contributor

@exvuma exvuma commented Jan 10, 2020

Checks asset manifest for the extensionless file matching the request first and then uses mapRequestToAsset to map the HTML equivalent if it doesn't exist.
fixes part of cloudflare/wrangler-legacy#980

Disclaimer:

  • One must have defined ASSET_MANIFEST to serve files without extensions. The technical reason is that we'd have to go through checking the cache and the KV for the extensionless asset (filename ) to validate it's there not an extensionless file present on every request before checking the namespace for the .html equivalent. That would add latency and be complicated so I vote not to do that. This is a rare edge case and maybe we should just start requiring asset manifest? Or just document this and see if anyone even runs into that.

@exvuma exvuma requested a review from a team January 10, 2020 20:16
Copy link
Contributor

@gabbifish gabbifish left a comment

Choose a reason for hiding this comment

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

Awesome work so far! Something that we really need to make sure of is that we're not breaking our backwards-compatible contract with the "Clean URL" spec--specifically, paths like /client/ should always map to /client/index.html. (https://en.wikipedia.org/wiki/Clean_URL)

^ this behavior above is what we have at the moment.

t.fail('Response was undefined')
}
})
test('getAssetFromKV evaluated the file matching the extensionless path first /client/ -> client', async t => {
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this map to client/index.html, consistent with https://en.wikipedia.org/wiki/Clean_URL?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The purpose of this PR is to not exclusively match html files and have raw files be an option (e.g. upload and serve a .env )

Copy link
Contributor

Choose a reason for hiding this comment

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

to back this one up: not all major static site generators adhere to that standard

@exvuma exvuma force-pushed the victoria/extensions branch from bb2c04d to 1269af0 Compare February 19, 2020 20:44
@exvuma
Copy link
Contributor Author

exvuma commented Feb 19, 2020

Awesome work so far! Something that we really need to make sure of is that we're not breaking our backwards-compatible contract with the "Clean URL" spec--specifically, paths like /client/ should always map to /client/index.html. (https://en.wikipedia.org/wiki/Clean_URL)

^ this behavior above is what we have at the moment.

Sorry it took me awhile to get back to this (it got lost in my email during vacay my B)! I think there is some confusion on the problem this PR is solving.

Before this PR

Before client would exclusively look at client/index.html at not client. mapRequestToAsset is always needed to clean extension-less URLs since it would only serve those files as HTML.

This PR

If client.somehash lives in the manifest, that file should be served and no URL cleaning is needed since it's already clean. mapRequestToAsset will run if the extension-less file is not in the manifest.

@exvuma exvuma requested review from a team and gabbifish February 19, 2020 21:07
t.fail('Response was undefined')
}
})
test('getAssetFromKV evaluated the file matching the extensionless path first /client/ -> client', async t => {
Copy link
Contributor

Choose a reason for hiding this comment

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

to back this one up: not all major static site generators adhere to that standard

@exvuma exvuma merged commit 0617aec into master Apr 7, 2020
@kristianfreeman kristianfreeman deleted the victoria/extensions branch May 2, 2022 15:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants