Skip to content

Commit

Permalink
fixed double bang
Browse files Browse the repository at this point in the history
  • Loading branch information
jpillora committed Jan 26, 2023
1 parent f847773 commit b19971e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
8 changes: 4 additions & 4 deletions handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
// set query from route
path := strings.TrimPrefix(r.URL.Path, "/")
var rest string
q.User, rest = splitHalf(path, "/")
// move to path with !
if strings.HasSuffix(rest, "!") {
if strings.HasSuffix(path, "!") {
q.MoveToPath = true
rest = strings.TrimSuffix(rest, "!")
path = strings.TrimRight(path, "!")
}
var rest string
q.User, rest = splitHalf(path, "/")
q.Program, q.Release = splitHalf(rest, "@")
// no program? treat first part as program, use default user
if q.Program == "" {
Expand Down
11 changes: 11 additions & 0 deletions handler/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ func TestMicro(t *testing.T) {
}
}

func TestMicroDoubleBang(t *testing.T) {
h := &handler.Handler{}
r := httptest.NewRequest("GET", "/micro!!", nil)
w := httptest.NewRecorder()
h.ServeHTTP(w, r)
t.Log(w.Body.String())
if w.Result().StatusCode != 200 {
t.Fatalf("failed to get micro!! asset status")
}
}

func TestGotty(t *testing.T) {
h := &handler.Handler{}
r := httptest.NewRequest("GET", "/yudai/gotty@v0.0.12", nil)
Expand Down

0 comments on commit b19971e

Please sign in to comment.