diff options
| author | Fuwn <[email protected]> | 2022-03-17 18:05:46 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-03-17 18:05:46 -0700 |
| commit | e42eec3abf7acbddb415715027153647902b2f09 (patch) | |
| tree | fe6ac8d6229b815416cbec07118656abdca26fcf | |
| parent | fix(readme): links (diff) | |
| download | capybara-e42eec3abf7acbddb415715027153647902b2f09.tar.xz capybara-e42eec3abf7acbddb415715027153647902b2f09.zip | |
feat: keep exact url from config
| -rw-r--r-- | Capybara.yaml | 14 | ||||
| -rw-r--r-- | 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) |