Skip to content

Commit

Permalink
Add support for slash in slug
Browse files Browse the repository at this point in the history
Fixes #12
  • Loading branch information
storvik committed Jan 7, 2024
1 parent 58287d3 commit d81f0f7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func NewServer(l *log.Logger, p string) *Server {

// Index and shortener routes
r.Get("/", indexHandler())
r.Get("/{slug}", s.shrtHandler())
r.Get("/*", s.shrtHandler())

// API routes
r.Route("/api", func(r chi.Router) {
Expand Down Expand Up @@ -105,7 +105,7 @@ func indexHandler() http.HandlerFunc {
func (s *Server) shrtHandler() http.HandlerFunc {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
t := time.Now()
slug := chi.URLParam(r, "slug")
slug := chi.URLParam(r, "*")
if slug == "" {
s.ErrorLog.Println("Could not get empty slug")
w.Header().Set("Content-Type", "text/html")
Expand Down

0 comments on commit d81f0f7

Please sign in to comment.