Skip to content

Commit

Permalink
Fix: handle provider id redirection (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
xjasonlyu authored Oct 13, 2023
1 parent 0def035 commit c38be54
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions route/redirect.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package route

import (
"net/http"
"net/url"
"strings"

"github.com/gin-gonic/gin"
Expand All @@ -17,19 +18,24 @@ func redirect(app *engine.Engine) gin.HandlerFunc {
queryKey = "redirect"
)
return func(c *gin.Context) {
if url := c.Query(queryKey); url != "" {
if link := c.Query(queryKey); link != "" {
var (
provider string
id string
)
if ss := strings.Split(url, separator); len(ss) > 1 {
if ss := strings.Split(link, separator); len(ss) > 1 {
provider, id = ss[0], ss[1]
}

var (
info any
err error
)
if id, err = url.QueryUnescape(id); err != nil {
abortWithError(c, err)
return
}

switch {
case app.IsActorProvider(provider):
info, err = app.GetActorInfoByProviderID(provider, id, true)
Expand Down

0 comments on commit c38be54

Please sign in to comment.