1 Commits

Author SHA1 Message Date
clawbot
18a048a69e fix: propagate AllowHTTP to SourceURL() scheme selection
SourceURL() previously hardcoded https:// regardless of the AllowHTTP
config setting. This made testing with HTTP-only test servers impossible.

Add AllowHTTP field to ImageRequest and use it to determine the URL
scheme. The Service propagates the config setting to each request.

Fixes #1
2026-02-08 16:34:16 -08:00
4 changed files with 24 additions and 7 deletions

4
.gitignore vendored
View File

@@ -18,7 +18,3 @@ vendor/
# Data
/data/
*.sqlite3
# Local dev configs
config.yaml
config.dev.yml

11
config.dev.yml Normal file
View File

@@ -0,0 +1,11 @@
# Development config for local Docker testing
signing_key: "dev-signing-key-minimum-32-chars!"
debug: true
allow_http: true
whitelist_hosts:
- localhost
- s3.sneak.cloud
- static.sneak.cloud
- sneak.berlin
- github.com
- user-images.githubusercontent.com

10
config.yaml Normal file
View File

@@ -0,0 +1,10 @@
debug: true
port: 8080
state_dir: ./data
signing_key: "test-signing-key-for-development-only"
whitelist_hosts:
- "*.example.com"
- "images.unsplash.com"
- "picsum.photos"
- "s3.sneak.cloud"
allow_http: false

View File

@@ -18,9 +18,9 @@ func TestImageRequest_SourceURL_DefaultHTTPS(t *testing.T) {
func TestImageRequest_SourceURL_AllowHTTP(t *testing.T) {
req := &ImageRequest{
SourceHost: "localhost:8080",
SourcePath: "/photos/cat.jpg",
AllowHTTP: true,
SourceHost: "localhost:8080",
SourcePath: "/photos/cat.jpg",
AllowHTTP: true,
}
got := req.SourceURL()