Allow passing the URL too since that's easier to copy-paste

This commit is contained in:
Gwilym Inzani 2024-04-03 11:08:31 +01:00
parent fe78711736
commit f633b04d3c

View file

@ -34,6 +34,10 @@ pub struct GwilymDecodeIter<'a> {
impl<'a> GwilymDecodeIter<'a> {
fn new(input: &'a str) -> anyhow::Result<Self> {
let input = input
.strip_prefix("https://agbrs.dev/crash#")
.unwrap_or(input);
let Some((input, version)) = input.rsplit_once('v') else {
anyhow::bail!("Does not contain version");
};
@ -161,4 +165,14 @@ mod test {
Ok(())
}
#[test]
fn should_strip_the_agbrsdev_prefix() -> anyhow::Result<()> {
assert_eq!(
&gwilym_decode("https://agbrs.dev/crash#2QI65Q69306Kv1")?.collect::<Vec<_>>(),
&[0x0800_16d3, 0x0800_315b, 0x0800_3243, 0x0800_0195]
);
Ok(())
}
}