Replace 'path' with 'file/path'
This commit is contained in:
parent
e2b6e01b27
commit
1c6c4d8444
10
iri.go
10
iri.go
|
@ -6,7 +6,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"net/url"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/valyala/fastjson"
|
||||
|
@ -134,7 +134,7 @@ func (i *IRIs) GobDecode(data []byte) error {
|
|||
|
||||
// AddPath concatenates el elements as a path to i
|
||||
func (i IRI) AddPath(el ...string) IRI {
|
||||
return IRI(fmt.Sprintf("%s/%s", i, path.Join(el...)))
|
||||
return IRI(filepath.Clean(filepath.Join(i.String(), filepath.Join(el...))))
|
||||
}
|
||||
|
||||
// GetID
|
||||
|
@ -250,7 +250,7 @@ func (i IRI) Equals(with IRI, checkScheme bool) bool {
|
|||
if strings.ToLower(u.Host) != strings.ToLower(uw.Host) {
|
||||
return false
|
||||
}
|
||||
if path.Clean(u.Path) != path.Clean(uw.Path) {
|
||||
if filepath.Clean(u.Path) != filepath.Clean(uw.Path) {
|
||||
return false
|
||||
}
|
||||
uq := u.Query()
|
||||
|
@ -311,11 +311,11 @@ func (i IRI) Contains(what IRI, checkScheme bool) bool {
|
|||
}
|
||||
p := u.Path
|
||||
if p != "" {
|
||||
p = path.Clean(p)
|
||||
p = filepath.Clean(p)
|
||||
}
|
||||
pw := uw.Path
|
||||
if pw != "" {
|
||||
pw = path.Clean(pw)
|
||||
pw = filepath.Clean(pw)
|
||||
}
|
||||
return strings.Contains(p, pw)
|
||||
}
|
||||
|
|
6
typer.go
6
typer.go
|
@ -2,7 +2,7 @@ package activitypub
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/go-ap/errors"
|
||||
|
@ -71,7 +71,7 @@ func (t CollectionPaths) Contains(typ CollectionPath) bool {
|
|||
// Split splits the IRI in an actor IRI and its CollectionPath
|
||||
// if the CollectionPath is found in the elements in the t CollectionPaths slice
|
||||
func (t CollectionPaths) Split(i IRI) (IRI, CollectionPath) {
|
||||
maybeActor, maybeCol := path.Split(i.String())
|
||||
maybeActor, maybeCol := filepath.Split(i.String())
|
||||
tt := CollectionPath(maybeCol)
|
||||
if !t.Contains(tt) {
|
||||
tt = ""
|
||||
|
@ -144,7 +144,7 @@ func (t CollectionPath) Of(i Item) Item {
|
|||
|
||||
// OfActor returns the base IRI of received i, if i represents an IRI matching CollectionPath type t
|
||||
func (t CollectionPath) OfActor(i IRI) (IRI, error) {
|
||||
maybeActor, maybeCol := path.Split(i.String())
|
||||
maybeActor, maybeCol := filepath.Split(i.String())
|
||||
if strings.ToLower(maybeCol) == strings.ToLower(string(t)) {
|
||||
maybeActor = strings.TrimRight(maybeActor, "/")
|
||||
return IRI(maybeActor), nil
|
||||
|
|
Reference in a new issue