diff options
author | Caidan Williams <caidan@internet.dev> | 2025-08-25 17:17:49 -0700 |
---|---|---|
committer | Caidan Williams <caidan@internet.dev> | 2025-08-25 17:18:15 -0700 |
commit | eb45154823323b0c7ecbd49b5896118b106cd762 (patch) | |
tree | 3c204c101db2db36d3c6eaea8c0094268e8941cb /bskyweb | |
parent | 685650b2964ffa5e86c122a410e4b9713c01dcf7 (diff) | |
download | voidsky-eb45154823323b0c7ecbd49b5896118b106cd762.tar.zst |
refactor: rename canonical filter to canonicalize_url for better clarity
- Rename filter from 'canonical' to 'canonicalize_url' to follow Pongo2 naming conventions - Update function name from filterCanonical to filterCanonicalizeURL - Update template usage in post.html and profile.html - Update test function name and all references
Diffstat (limited to 'bskyweb')
-rw-r--r-- | bskyweb/cmd/bskyweb/filters.go | 4 | ||||
-rw-r--r-- | bskyweb/cmd/bskyweb/filters_test.go | 8 | ||||
-rw-r--r-- | bskyweb/templates/post.html | 2 | ||||
-rw-r--r-- | bskyweb/templates/profile.html | 2 |
4 files changed, 8 insertions, 8 deletions
diff --git a/bskyweb/cmd/bskyweb/filters.go b/bskyweb/cmd/bskyweb/filters.go index 0b882780b..a92cc606b 100644 --- a/bskyweb/cmd/bskyweb/filters.go +++ b/bskyweb/cmd/bskyweb/filters.go @@ -7,10 +7,10 @@ import ( ) func init() { - pongo2.RegisterFilter("canonical", filterCanonical) + pongo2.RegisterFilter("canonicalize_url", filterCanonicalizeURL) } -func filterCanonical(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *pongo2.Error) { +func filterCanonicalizeURL(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *pongo2.Error) { urlStr := in.String() parsedURL, err := url.Parse(urlStr) diff --git a/bskyweb/cmd/bskyweb/filters_test.go b/bskyweb/cmd/bskyweb/filters_test.go index 2a3fc5b86..a63ad0317 100644 --- a/bskyweb/cmd/bskyweb/filters_test.go +++ b/bskyweb/cmd/bskyweb/filters_test.go @@ -6,7 +6,7 @@ import ( "github.com/flosch/pongo2/v6" ) -func TestCanonicalFilter(t *testing.T) { +func TestCanonicalizeURLFilter(t *testing.T) { tests := []struct { name string input string @@ -47,14 +47,14 @@ func TestCanonicalFilter(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { inputValue := pongo2.AsValue(tt.input) - result, err := filterCanonical(inputValue, nil) + result, err := filterCanonicalizeURL(inputValue, nil) if err != nil { - t.Errorf("filterCanonical() error = %v", err) + t.Errorf("filterCanonicalizeURL() error = %v", err) return } if result.String() != tt.expected { - t.Errorf("filterCanonical() = %v, want %v", result.String(), tt.expected) + t.Errorf("filterCanonicalizeURL() = %v, want %v", result.String(), tt.expected) } }) } diff --git a/bskyweb/templates/post.html b/bskyweb/templates/post.html index a290b94e7..1f3f6da4e 100644 --- a/bskyweb/templates/post.html +++ b/bskyweb/templates/post.html @@ -14,7 +14,7 @@ <meta property="profile:username" content="{{ profileView.Handle }}"> {%- if requestURI %} <meta property="og:url" content="{{ requestURI }}"> - <link rel="canonical" href="{{ requestURI|canonical }}" /> + <link rel="canonical" href="{{ requestURI|canonicalize_url }}" /> {% endif -%} {%- if postView.Author.DisplayName %} <meta property="og:title" content="{{ postView.Author.DisplayName }} (@{{ postView.Author.Handle }})"> diff --git a/bskyweb/templates/profile.html b/bskyweb/templates/profile.html index 449caa39f..8506a9cff 100644 --- a/bskyweb/templates/profile.html +++ b/bskyweb/templates/profile.html @@ -15,7 +15,7 @@ <meta property="profile:username" content="{{ profileView.Handle }}"> {%- if requestURI %} <meta property="og:url" content="{{ requestURI }}"> - <link rel="canonical" href="{{ requestURI|canonical }}" /> + <link rel="canonical" href="{{ requestURI|canonicalize_url }}" /> {% endif -%} {%- if profileView.DisplayName %} <meta property="og:title" content="{{ profileView.DisplayName }} (@{{ profileView.Handle }})"> |