Initial commit
This commit is contained in:
33
internal/project/local.go
Normal file
33
internal/project/local.go
Normal file
@ -0,0 +1,33 @@
|
||||
package project
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"gopkg.in/src-d/go-billy.v4"
|
||||
)
|
||||
|
||||
const LocalScheme = "local"
|
||||
const FileScheme = "file"
|
||||
|
||||
type LocalFetcher struct{}
|
||||
|
||||
func (f *LocalFetcher) Fetch(url *url.URL) (billy.Filesystem, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (f *LocalFetcher) Match(url *url.URL) bool {
|
||||
if url.Scheme == LocalScheme || url.Scheme == FileScheme {
|
||||
return true
|
||||
}
|
||||
|
||||
return isFilesystemPath(url.Path)
|
||||
}
|
||||
|
||||
func NewLocalFetcher() *LocalFetcher {
|
||||
return &LocalFetcher{}
|
||||
}
|
||||
|
||||
func isFilesystemPath(path string) bool {
|
||||
return strings.HasPrefix(path, "./") || strings.HasPrefix(path, "/")
|
||||
}
|
Reference in New Issue
Block a user