Skip to content

Commit

Permalink
feat: Switch to data-encoding for base64 (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko authored Jan 13, 2023
1 parent fb8e9ad commit 1ba3981
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ all-features = true
url = "2.1.1"
serde = { version = "1.0.104", features = ["derive"] }
serde_json = "1.0.48"
base64 = "0.13.0"
unicode-id = "0.3"
if_chain = "1.0.0"
scroll = { version = "0.10.1", features = ["derive"], optional = true }
data-encoding = "2.3.3"

[build-dependencies]
rustc_version = "0.2.3"
Expand Down
4 changes: 3 additions & 1 deletion src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ pub fn decode_data_url(url: &str) -> Result<DecodedMap> {
fail!(Error::InvalidDataUrl);
}
let data_b64 = &url[DATA_PREAMBLE.len()..];
let data = base64::decode(data_b64).map_err(|_| Error::InvalidDataUrl)?;
let data = data_encoding::BASE64
.decode(data_b64.as_bytes())
.map_err(|_| Error::InvalidDataUrl)?;
decode_slice(&data[..])
}

Expand Down

0 comments on commit 1ba3981

Please sign in to comment.