Compare commits
2 commits
5898da55e3
...
09e7c1d8bd
Author | SHA1 | Date | |
---|---|---|---|
09e7c1d8bd | |||
1e36edf499 |
3 changed files with 26 additions and 15 deletions
|
@ -7,7 +7,7 @@ All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
### 🐛 Bug Fixes
|
### 🐛 Bug Fixes
|
||||||
|
|
||||||
- PR comment emoji prefix detection - ([ed0fbc3](https://codeberg.org/ThetaDev/artifactview/commit/ed0fbc38b2a1e76f070697f766812a20c84149ee))
|
- PR comment emoji prefix detection - ([1e36edf](https://codeberg.org/ThetaDev/artifactview/commit/1e36edf49978e8ba24a85d4663ff3ebaf9642a29))
|
||||||
|
|
||||||
|
|
||||||
## [v0.4.1](https://codeberg.org/ThetaDev/artifactview/compare/v0.4.0..v0.4.1) - 2024-06-22
|
## [v0.4.1](https://codeberg.org/ThetaDev/artifactview/compare/v0.4.0..v0.4.1) - 2024-06-22
|
||||||
|
|
15
src/app.rs
15
src/app.rs
|
@ -1,5 +1,4 @@
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
|
||||||
collections::{BTreeMap, HashMap},
|
collections::{BTreeMap, HashMap},
|
||||||
fmt::Write,
|
fmt::Write,
|
||||||
net::{IpAddr, SocketAddr},
|
net::{IpAddr, SocketAddr},
|
||||||
|
@ -866,19 +865,7 @@ fn pr_comment_text(p: PrCommentTextParams) -> String {
|
||||||
};
|
};
|
||||||
|
|
||||||
let write_link_icon = |s: &mut String, title: &str, href: &str| {
|
let write_link_icon = |s: &mut String, title: &str, href: &str| {
|
||||||
// Move leading emoji into a prefix variable since including them in the link does not look good
|
let (title_pfx, title) = util::split_icon_prefix(title);
|
||||||
let mut title_pfx = String::new();
|
|
||||||
let mut title = Cow::Borrowed(title);
|
|
||||||
if let Some((i, c)) = title
|
|
||||||
.char_indices()
|
|
||||||
.find(|(_, c)| c.is_ascii() || c.is_alphanumeric())
|
|
||||||
{
|
|
||||||
if i > 0 && c == ' ' {
|
|
||||||
title[..i + 1].clone_into(&mut title_pfx);
|
|
||||||
title = title[i + 1..].to_owned().into();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_ = write!(
|
_ = write!(
|
||||||
s,
|
s,
|
||||||
r#"{title_pfx}<a href="{href}" target="_blank" rel="noopener noreferrer">{title}</a>"#,
|
r#"{title_pfx}<a href="{href}" target="_blank" rel="noopener noreferrer">{title}</a>"#,
|
||||||
|
|
24
src/util.rs
24
src/util.rs
|
@ -302,6 +302,18 @@ pub fn extract_delim<'a>(s: &'a str, start: &str, end: &str) -> Option<&'a str>
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn split_icon_prefix(s: &str) -> (&str, &str) {
|
||||||
|
if let Some((i, c)) = s
|
||||||
|
.char_indices()
|
||||||
|
.find(|(_, c)| c.is_ascii() || c.is_alphanumeric())
|
||||||
|
{
|
||||||
|
if i > 0 && c == ' ' && s.get(i + 1..).is_some() {
|
||||||
|
return (&s[..i + 1], &s[i + 1..]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
("", s)
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub(crate) mod tests {
|
pub(crate) mod tests {
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
@ -390,4 +402,16 @@ pub(crate) mod tests {
|
||||||
let res = super::filename_ext(filename);
|
let res = super::filename_ext(filename);
|
||||||
assert_eq!(res, expect);
|
assert_eq!(res, expect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[rstest]
|
||||||
|
#[case("🧪 Test", ("🧪 ", "Test"))]
|
||||||
|
#[case("🧪👨👩👦 Test", ("🧪👨👩👦 ", "Test"))]
|
||||||
|
#[case("🧪 👨👩👦 Test", ("🧪 ", "👨👩👦 Test"))]
|
||||||
|
#[case("", ("", ""))]
|
||||||
|
#[case("Test", ("", "Test"))]
|
||||||
|
#[case("運命 Test", ("", "運命 Test"))]
|
||||||
|
fn split_icon_prefix(#[case] s: &str, #[case] expect: (&str, &str)) {
|
||||||
|
let res = super::split_icon_prefix(s);
|
||||||
|
assert_eq!(res, expect);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue