photoprism/pkg/clean/ascii_test.go
Michael Mayer c5f6a28448 Config: Add PHOTOPRISM_HTTP_CORS option for CDN users #3931 #3940
In addition, the Access-Control-Allow-Origin header is set to the same
URL if an Origin header is found in the request (experimental).

Signed-off-by: Michael Mayer <michael@photoprism.app>
2024-01-15 13:06:27 +01:00

34 lines
961 B
Go

package clean
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestASCII(t *testing.T) {
t.Run("URL", func(t *testing.T) {
result := ASCII("https://docs.photoprism.app/getting-started/config-options/#file-converters")
assert.Equal(t, "https://docs.photoprism.app/getting-started/config-options/#file-converters", result)
})
t.Run("Emoji", func(t *testing.T) {
result := ASCII("Hello 👍")
assert.Equal(t, "Hello ", result)
})
t.Run("EmojiURL", func(t *testing.T) {
result := ASCII("https://docs.photoprism.app/getting-started 👍/config-options/#file-converters")
assert.Equal(t, "https://docs.photoprism.app/getting-started /config-options/#file-converters", result)
})
}
func BenchmarkASCII(b *testing.B) {
for n := 0; n < b.N; n++ {
ASCII("https://docs.photoprism.app/getting-started 👍/config-options/#file-converters")
}
}
func BenchmarkASCIIEmpty(b *testing.B) {
for n := 0; n < b.N; n++ {
ASCII("")
}
}