diff --git a/src/utils.rs b/src/utils.rs index 5977576..d45e6b2 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1154,3 +1154,10 @@ async fn test_fetching_ws() { assert!(post.ws_url.starts_with("wss://k8s-lb.wss.redditmedia.com/link/")); } } + +#[test] +fn test_rewriting_image_links() { + let input = r#"

https://preview.redd.it/zq21ggkj2xo31.png?width=2560&format=png&auto=webp&s=539d8050628ec1190cac26468fe99cc66b6071ab

https://preview.redd.it/vty9ocij2xo31.png?width=2560&format=png&auto=webp&s=fc7c7ef993a5e9ef656d5f5d9cf8290a0a1df877

https://preview.redd.it/bdfdxkjj2xo31.png?width=2560&format=png&auto=webp&s=d0fa420ece27605e882e89cb4711d75d774322ac

caption 1

"#; + let output = r#"

/preview/pre/zq21ggkj2xo31.png?width=2560&format=png&auto=webp&s=539d8050628ec1190cac26468fe99cc66b6071ab

/preview/pre/vty9ocij2xo31.png?width=2560&format=png&auto=webp&s=fc7c7ef993a5e9ef656d5f5d9cf8290a0a1df877

/preview/pre/bdfdxkjj2xo31.png?width=2560&format=png&auto=webp&s=d0fa420ece27605e882e89cb4711d75d774322ac

caption 1

"#; + assert_eq!(rewrite_urls(input), output); +}