fix broken IsLastPathPart

This commit is contained in:
perennial
2024-10-28 21:29:59 +11:00
parent 4a943d089c
commit 3c576b9565
2 changed files with 10 additions and 4 deletions
+4 -4
View File
@@ -14,20 +14,20 @@
</div>
<div class="card-body p-0">
<!-- Replicate the thumbnail-tt structure -->
<p class="text-truncate mb-0">
<span class="fw-bold text-body-secondary text-decoration-none">{{ .Title }}</span>
<p class="text-truncate fw-bold text-body-secondary text-decoration-none mb-0">
{{ .Title }}
</p>
<!-- Replicate the thumbnail-at structure -->
<div class="d-flex align-items-center mt-1">
<img src="/img/deleted.png" class="rounded-circle me-1" style="width: 24px; height: 24px" />
<span class="text-muted">Deleted or Private</span>
<span class="text-body-secondary text-truncate">Deleted or Private</span>
</div>
</div>
{{- else if .ID }}
{{ include "thumbnail-dt" . }}
<div class="card-body p-0">
{{ include "thumbnail-tt" . }}
{{- if isFirstPathPart (CurrentPath, "/users") == false || isLastPathPart (CurrentPath, "/bookmarks") == true }}
{{- if isFirstPathPart (CurrentPath, "/users") == false || (isFirstPathPart (CurrentPath, "/users") == true && isLastPathPart (CurrentPath, "/bookmarks") == true) }}
{{ include "thumbnail-at" . }}
{{- end }}
</div>
+6
View File
@@ -323,6 +323,12 @@ func IsFirstPathPart(currentPath, pathToCheck string) bool {
// IsLastPathPart checks if the last part of the current path matches the given path
func IsLastPathPart(currentPath, pathToCheck string) bool {
// Parse the currentPath to remove query parameters
u, err := url.Parse(currentPath)
if err == nil {
currentPath = u.Path
}
// Trim any trailing slashes from both paths
currentPath = strings.TrimRight(currentPath, "/")
pathToCheck = strings.TrimRight(pathToCheck, "/")