feat(alias): support proxy and direct together
This commit is contained in:
@ -2,9 +2,12 @@ package fs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/alist-org/alist/v3/internal/model"
|
||||
"github.com/alist-org/alist/v3/internal/op"
|
||||
"github.com/alist-org/alist/v3/server/common"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
@ -13,5 +16,14 @@ func link(ctx context.Context, path string, args model.LinkArgs) (*model.Link, m
|
||||
if err != nil {
|
||||
return nil, nil, errors.WithMessage(err, "failed get storage")
|
||||
}
|
||||
return op.Link(ctx, storage, actualPath, args)
|
||||
l, obj, err := op.Link(ctx, storage, actualPath, args)
|
||||
if err != nil {
|
||||
return nil, nil, errors.WithMessage(err, "failed link")
|
||||
}
|
||||
if l.URL != "" && !strings.HasPrefix(l.URL, "http://") && !strings.HasPrefix(l.URL, "https://") {
|
||||
if c, ok := ctx.(*gin.Context); ok {
|
||||
l.URL = common.GetApiUrl(c.Request) + l.URL
|
||||
}
|
||||
}
|
||||
return l, obj, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user