mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-09-03 00:23:49 +00:00
Recognize hashtags in posts on Akkoma and Pixelfed servers (#2261)
Fixes #2260
This commit is contained in:
parent
7a14ce9e6f
commit
5591a6d52c
2 changed files with 31 additions and 1 deletions
|
@ -146,7 +146,8 @@ public enum SettingsStartingPoint {
|
|||
}
|
||||
|
||||
public func handleStatus(status: AnyStatus, url: URL) -> OpenURLAction.Result {
|
||||
if url.pathComponents.count == 3, url.pathComponents[1] == "tags",
|
||||
if url.pathComponents.count == 3,
|
||||
url.pathComponents[1] == "tags" || url.pathComponents[1] == "tag",
|
||||
url.host() == status.account.url?.host(),
|
||||
let tag = url.pathComponents.last
|
||||
{
|
||||
|
@ -155,6 +156,17 @@ public enum SettingsStartingPoint {
|
|||
// That is on the same host as the person that posted the tag,
|
||||
// i.e. not a link that matches the pattern but elsewhere on the internet
|
||||
// In those circumstances, hijack the link and goto the tags page instead
|
||||
// The second is "tags" on Mastodon and "tag" on Akkoma.
|
||||
navigate(to: .hashTag(tag: tag, account: nil))
|
||||
return .handled
|
||||
} else if url.pathComponents.count == 4,
|
||||
url.pathComponents[1] == "discover",
|
||||
url.pathComponents[2] == "tags",
|
||||
url.host() == status.account.url?.host(),
|
||||
let tag = url.pathComponents.last
|
||||
{
|
||||
// Similar to above, but for ["/", "discover", "tags", "tagname"]
|
||||
// as used in Pixelfed
|
||||
navigate(to: .hashTag(tag: tag, account: nil))
|
||||
return .handled
|
||||
} else if let mention = status.mentions.first(where: { $0.url == url }) {
|
||||
|
|
|
@ -23,6 +23,24 @@ func testRouterTagsURL() {
|
|||
#expect(router.path.first == .hashTag(tag: "test", account: nil))
|
||||
}
|
||||
|
||||
@Test
|
||||
@MainActor
|
||||
func testRouterTagsAkkomaURL() {
|
||||
let router = RouterPath()
|
||||
let url = URL(string: "https://genserver.social/tag/test")!
|
||||
_ = router.handle(url: url)
|
||||
#expect(router.path.first == .hashTag(tag: "test", account: nil))
|
||||
}
|
||||
|
||||
@Test
|
||||
@MainActor
|
||||
func testRouterTagsPixelfedURL() {
|
||||
let router = RouterPath()
|
||||
let url = URL(string: "https://pixelfed.social/discover/tags/test")!
|
||||
_ = router.handle(url: url)
|
||||
#expect(router.path.first == .hashTag(tag: "test", account: nil))
|
||||
}
|
||||
|
||||
@Test
|
||||
@MainActor
|
||||
func testRouterLocalStatusURL() {
|
||||
|
|
Loading…
Reference in a new issue