From e42eec3abf7acbddb415715027153647902b2f09 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 17 Mar 2022 18:05:46 -0700 Subject: feat: keep exact url from config --- Capybara.yaml | 14 +++++++++----- capybara.go | 9 +++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Capybara.yaml b/Capybara.yaml index bc9e04b..a3b1eb3 100644 --- a/Capybara.yaml +++ b/Capybara.yaml @@ -1,6 +1,10 @@ capybara: - keep_gemini: # A list of hosts where if the host is present; the URL will not be proxied - - fuwn.me # - # Example: - # Proxied: `gemini://gem.rest` becomes `/proxy/gem.rest` - # Not proxied (present in `capybara.keep_gemini`): `gemini://gem.rest` is kept + keep_gemini: # A list of hosts where if the host is present; the URL will not be proxied + - distro.tube # + # Example: + # Proxied: `gemini://gem.rest` becomes `/proxy/gem.rest` + # Not proxied (present in `capybara.keep_gemini`): `gemini://gem.rest` is kept + + keep_gemini_exact: # A list of URLs where if the URL is present; the URL will not be proxied + - fuwn.me/skills # + # Similar to `keep_gemini` except only keeps exact URLs diff --git a/capybara.go b/capybara.go index b60d728..9117a99 100644 --- a/capybara.go +++ b/capybara.go @@ -21,6 +21,7 @@ import ( ) var keepGeminiLinks []string +var keepGeminiExactLinks []string func init() { viper.SetConfigName("Capybara.yaml") @@ -32,6 +33,7 @@ func init() { if err := viper.ReadInConfig(); err == nil { keepGeminiLinks = viper.GetStringSlice("capybara.keep_gemini") + keepGeminiExactLinks = viper.GetStringSlice("capybara.keep_gemini_exact") } } @@ -125,12 +127,19 @@ var gemtextPage = template.Must(template. if u.Scheme == "" || u.Scheme == "gemini" { keepGemini := false + for _, v := range keepGeminiLinks { if v == u.Host { keepGemini = true } } + for _, v := range keepGeminiExactLinks { + if "gemini://"+v == u.String() { + keepGemini = true + } + } + if !keepGemini { if u.Host != ctx.Root.Host { u.Path = fmt.Sprintf("/proxy/%s%s", u.Host, u.Path) -- cgit v1.2.3