Skip to content

Commit

Permalink
unwrap FB messenger links
Browse files Browse the repository at this point in the history
  • Loading branch information
liias committed Aug 15, 2024
1 parent b2a58f2 commit ecdc0aa
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.5.8] - 2024-08-15

### Added

- Unwrap URLs (Facebook Messenger, Office 365 Safe Links). Fixes #202

## [0.5.7] - 2024-07-27

### Fixed
Expand Down Expand Up @@ -303,7 +309,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

Initial Release

[unreleased]: https://github.com/Browsers-software/browsers/compare/0.5.7...HEAD
[unreleased]: https://github.com/Browsers-software/browsers/compare/0.5.8...HEAD

[0.5.8]: https://github.com/Browsers-software/browsers/releases/tag/0.5.8

[0.5.7]: https://github.com/Browsers-software/browsers/releases/tag/0.5.7

Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "browsers"
version = "0.5.7"
version = "0.5.8"
authors = ["Madis Liias <[email protected]>"]
edition = "2021"
description = "Browsers"
Expand Down
16 changes: 12 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,17 +625,25 @@ pub fn unwrap_url(url_str: &str, behavioral_settings: &BehavioralConfig) -> Stri
let url = url_maybe.unwrap();

let transformed_url = url.domain().and_then(|domain| {
let is_safelinks = domain
.to_lowercase()
.ends_with("safelinks.protection.outlook.com");
return if is_safelinks {
let domain_lowercase = domain.to_lowercase();

return if domain_lowercase.ends_with("safelinks.protection.outlook.com") {
let query_pairs: Parse = url.query_pairs();

let target_url_maybe: Option<String> = query_pairs
.into_iter()
.find(|(key, _)| key == "url")
.map(|(_, value)| value.to_string());

target_url_maybe
} else if domain_lowercase.ends_with("l.messenger.com") {
let query_pairs: Parse = url.query_pairs();

let target_url_maybe: Option<String> = query_pairs
.into_iter()
.find(|(key, _)| key == "u")
.map(|(_, value)| value.to_string());

target_url_maybe
} else {
None
Expand Down

0 comments on commit ecdc0aa

Please sign in to comment.