Bluesky app fork with some witchin' additions 💫

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

+8 -8
+2 -2
bskyweb/cmd/bskyweb/filters.go
··· 7 7 ) 8 8 9 9 func init() { 10 - pongo2.RegisterFilter("canonical", filterCanonical) 10 + pongo2.RegisterFilter("canonicalize_url", filterCanonicalizeURL) 11 11 } 12 12 13 - func filterCanonical(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *pongo2.Error) { 13 + func filterCanonicalizeURL(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *pongo2.Error) { 14 14 urlStr := in.String() 15 15 16 16 parsedURL, err := url.Parse(urlStr)
+4 -4
bskyweb/cmd/bskyweb/filters_test.go
··· 6 6 "github.com/flosch/pongo2/v6" 7 7 ) 8 8 9 - func TestCanonicalFilter(t *testing.T) { 9 + func TestCanonicalizeURLFilter(t *testing.T) { 10 10 tests := []struct { 11 11 name string 12 12 input string ··· 47 47 for _, tt := range tests { 48 48 t.Run(tt.name, func(t *testing.T) { 49 49 inputValue := pongo2.AsValue(tt.input) 50 - result, err := filterCanonical(inputValue, nil) 50 + result, err := filterCanonicalizeURL(inputValue, nil) 51 51 if err != nil { 52 - t.Errorf("filterCanonical() error = %v", err) 52 + t.Errorf("filterCanonicalizeURL() error = %v", err) 53 53 return 54 54 } 55 55 56 56 if result.String() != tt.expected { 57 - t.Errorf("filterCanonical() = %v, want %v", result.String(), tt.expected) 57 + t.Errorf("filterCanonicalizeURL() = %v, want %v", result.String(), tt.expected) 58 58 } 59 59 }) 60 60 }
+1 -1
bskyweb/templates/post.html
··· 14 14 <meta property="profile:username" content="{{ profileView.Handle }}"> 15 15 {%- if requestURI %} 16 16 <meta property="og:url" content="{{ requestURI }}"> 17 - <link rel="canonical" href="{{ requestURI|canonical }}" /> 17 + <link rel="canonical" href="{{ requestURI|canonicalize_url }}" /> 18 18 {% endif -%} 19 19 {%- if postView.Author.DisplayName %} 20 20 <meta property="og:title" content="{{ postView.Author.DisplayName }} (@{{ postView.Author.Handle }})">
+1 -1
bskyweb/templates/profile.html
··· 15 15 <meta property="profile:username" content="{{ profileView.Handle }}"> 16 16 {%- if requestURI %} 17 17 <meta property="og:url" content="{{ requestURI }}"> 18 - <link rel="canonical" href="{{ requestURI|canonical }}" /> 18 + <link rel="canonical" href="{{ requestURI|canonicalize_url }}" /> 19 19 {% endif -%} 20 20 {%- if profileView.DisplayName %} 21 21 <meta property="og:title" content="{{ profileView.DisplayName }} (@{{ profileView.Handle }})">