🐛 Don't crash if subbed page matches user dir pattern but doesn't have more

Fixes #157
This commit is contained in:
makeworld 2020-12-23 23:57:18 -05:00
parent b50347177b
commit 6e3e8a0584
3 changed files with 8 additions and 3 deletions

View File

@ -4,6 +4,11 @@ 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).
## [1.7.2] - 2020-12-21
### Fixed
- Viewing subscriptions after subscribing to a certain user page won't crash Amfora (#157)
## [1.7.1] - 2020-12-21
### Fixed
- Fixed bug that caused Amfora to crash when subscribing to a page (#151)

View File

@ -11,7 +11,7 @@ import (
)
var (
version = "v1.7.1"
version = "v1.7.2"
commit = "unknown"
builtBy = "unknown"
)

View File

@ -112,14 +112,14 @@ func GetPageEntries() *PageEntries {
// Path is title
title := parsed.Path
if strings.HasPrefix(title, "/~") {
if strings.HasPrefix(title, "/~") && title != "/~" {
// A user dir
title = title[2:] // Remove beginning slash and tilde
// Remove trailing slash if the root of a user dir is being tracked
if strings.Count(title, "/") <= 1 && title[len(title)-1] == '/' {
title = title[:len(title)-1]
}
} else if strings.HasPrefix(title, "/users/") {
} else if strings.HasPrefix(title, "/users/") && title != "/users/" {
// "/users/" is removed for aesthetics when tracking hosted users
title = strings.TrimPrefix(title, "/users/")
title = strings.TrimPrefix(title, "~") // Remove leading tilde