Skip to content

Commit

Permalink
fix: rendered view of meta.json file (#187)
Browse files Browse the repository at this point in the history
This page previously was a 404 for the HTML view, but a 200 when
`curl`ing.

http://jsr.test/@std/expect/meta.json
  • Loading branch information
lucacasonato authored Mar 5, 2024
1 parent 2762cd3 commit 537ed5a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion api/src/api/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,13 @@ pub async fn get_source_handler(
};
let version = maybe_version.ok_or(ApiError::PackageVersionNotFound)?;

let file = if path == format!("{}_meta.json", version.version) {
let file = if path == "meta.json" {
let source_file_path = crate::gcs_paths::package_metadata(&scope, &package);
buckets
.modules_bucket
.download(source_file_path.into())
.await?
} else if path == format!("{}_meta.json", version.version) {
let source_file_path =
crate::gcs_paths::version_metadata(&scope, &package, &version.version);
buckets
Expand Down
7 changes: 6 additions & 1 deletion frontend/routes/package/source.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ export const handler: Handlers<Data, State> = {
});
}
let sourcePath = "/" + (ctx.params.path ?? "");
if (ctx.params.version === "meta.json" && ctx.params.path === "") {
sourcePath = "meta.json";
ctx.params.version = "latest";
}
if (ctx.params.version.endsWith("_meta.json") && ctx.params.path === "") {
sourcePath = ctx.params.version;
ctx.params.version = ctx.params.version.slice(0, -10);
Expand Down Expand Up @@ -203,5 +207,6 @@ export const handler: Handlers<Data, State> = {
};

export const config: RouteConfig = {
routeOverride: "/@:scope/:package/:version(\\d+\\.\\d+\\.\\d+.*?)/:path*",
routeOverride:
"/@:scope/:package/:version((?:\\d+\\.\\d+\\.\\d+.*?)|meta\.json)/:path*",
};

0 comments on commit 537ed5a

Please sign in to comment.