Skip to content

Commit

Permalink
fix: move redirects to top of serialized file (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Aug 24, 2023
1 parent 5a2eb90 commit 74201e8
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,15 @@ impl NpmContent {
#[derive(Debug, Clone, Serialize, Deserialize, Hash)]
pub struct LockfileContent {
version: String,
// Mapping between URLs and their checksums for "http:" and "https:" deps
// have redirects at the top of the file so they're more easily auditable
#[serde(skip_serializing_if = "BTreeMap::is_empty")]
#[serde(default)]
pub redirects: BTreeMap<String, String>,
/// Mapping between URLs and their checksums for "http:" and "https:" deps
remote: BTreeMap<String, String>,
#[serde(skip_serializing_if = "NpmContent::is_empty")]
#[serde(default)]
pub npm: NpmContent,
#[serde(skip_serializing_if = "BTreeMap::is_empty")]
#[serde(default)]
pub redirects: BTreeMap<String, String>,
}

impl LockfileContent {
Expand Down Expand Up @@ -574,10 +575,10 @@ mod tests {
PathBuf::from("/foo/deno.lock"),
r#"{
"version": "2",
"remote": {},
"redirects": {
"https://deno.land/x/std/mod.ts": "https://deno.land/std@0.190.0/mod.ts"
}
},
"remote": {}
}"#,
false,
)
Expand All @@ -590,11 +591,11 @@ mod tests {
lockfile.as_json_string(),
r#"{
"version": "2",
"remote": {},
"redirects": {
"https://deno.land/x/other/mod.ts": "https://deno.land/x/other@0.1.0/mod.ts",
"https://deno.land/x/std/mod.ts": "https://deno.land/std@0.190.0/mod.ts"
}
},
"remote": {}
}
"#,
);
Expand Down

0 comments on commit 74201e8

Please sign in to comment.