From a7da1394c280abffe3aea3c4e1dfb3fe53887f02 Mon Sep 17 00:00:00 2001 From: Tangled Date: Fri, 21 Mar 2025 06:33:37 +0000 Subject: [PATCH] repoguard: allow repo parameter formats like /handle/repo closes #42 by stripping one leading slash from the repo parameter. also fixes a minor issue with the nix develop shellhook. this kinda hacky fix is tested with the following commands: ``` nix build .#repoguard SSH_ORIGINAL_COMMAND="git-upload-pack '/soopy.moe/test-repo'" ./result/bin/repoguard -log-path /tmp/ASDUJBIf-repoguard.log -user git SSH_ORIGINAL_COMMAND="git-upload-pack 'soopy.moe/test-repo'" ./result/bin/repoguard -log-path /tmp/ASDUJBIf-repoguard.log -user git ``` --- cmd/repoguard/main.go | 7 ++++--- flake.nix | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/repoguard/main.go b/cmd/repoguard/main.go index 7dd0c6c9..3ed88102 100644 --- a/cmd/repoguard/main.go +++ b/cmd/repoguard/main.go @@ -66,14 +66,15 @@ func main() { gitCommand := cmdParts[0] // did:foo/repo-name or - // handle/repo-name + // handle/repo-name or + // any of the above with a leading slash (/) - components := strings.Split(strings.Trim(cmdParts[1], "'"), "/") + components := strings.Split(strings.TrimPrefix(strings.Trim(cmdParts[1], "'"), "/"), "/") logEvent("Command components", map[string]interface{}{ "components": components, }) if len(components) != 2 { - exitWithLog("invalid repo format, needs /") + exitWithLog("invalid repo format, needs / or //") } didOrHandle := components[0] diff --git a/flake.nix b/flake.nix index dbbdcd81..2aa2055e 100644 --- a/flake.nix +++ b/flake.nix @@ -152,6 +152,7 @@ shellHook = '' cp -f ${htmx-src} appview/pages/static/htmx.min.js cp -f ${lucide-src} appview/pages/static/lucide.min.js + mkdir -p appview/pages/static/fonts/ cp -f ${ia-fonts-src}/"iA Writer Quattro"/Static/*.ttf appview/pages/static/fonts/ cp -f ${ia-fonts-src}/"iA Writer Mono"/Static/*.ttf appview/pages/static/fonts/ ''; -- 2.54.0