mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-21 14:17:08 +00:00
Cleanup URL tracking tests. (#5181)
This commit is contained in:
parent
2e8687e203
commit
7d5cb9de49
|
@ -379,11 +379,14 @@ mod tests {
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
const URL_WITH_TRACKING: &str = "https://example.com/path/123?utm_content=buffercf3b2&utm_medium=social&user+name=random+user&id=123";
|
||||||
|
const URL_TRACKING_REMOVED: &str = "https://example.com/path/123?user+name=random+user&id=123";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_clean_url_params() -> LemmyResult<()> {
|
fn test_clean_url_params() -> LemmyResult<()> {
|
||||||
let url = Url::parse("https://example.com/path/123?utm_content=buffercf3b2&utm_medium=social&user+name=random+user&id=123")?;
|
let url = Url::parse(URL_WITH_TRACKING)?;
|
||||||
let cleaned = clean_url(&url);
|
let cleaned = clean_url(&url);
|
||||||
let expected = Url::parse("https://example.com/path/123?user+name=random+user&id=123")?;
|
let expected = Url::parse(URL_TRACKING_REMOVED)?;
|
||||||
assert_eq!(expected.to_string(), cleaned.to_string());
|
assert_eq!(expected.to_string(), cleaned.to_string());
|
||||||
|
|
||||||
let url = Url::parse("https://example.com/path/123")?;
|
let url = Url::parse("https://example.com/path/123")?;
|
||||||
|
@ -395,9 +398,9 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_clean_body() -> LemmyResult<()> {
|
fn test_clean_body() -> LemmyResult<()> {
|
||||||
let text = "[a link](https://example.com/path/123?utm_content=buffercf3b2&utm_medium=social&user+name=random+user&id=123)";
|
let text = format!("[a link]({URL_WITH_TRACKING})");
|
||||||
let cleaned = clean_urls_in_text(text);
|
let cleaned = clean_urls_in_text(&text);
|
||||||
let expected = "[a link](https://example.com/path/123?user+name=random+user&id=123)";
|
let expected = format!("[a link]({URL_TRACKING_REMOVED})");
|
||||||
assert_eq!(expected.to_string(), cleaned.to_string());
|
assert_eq!(expected.to_string(), cleaned.to_string());
|
||||||
|
|
||||||
let text = "[a link](https://example.com/path/123)";
|
let text = "[a link](https://example.com/path/123)";
|
||||||
|
|
Loading…
Reference in a new issue