https://github.com/hirokisan/pagepath
Golang library for handling and matching page paths
https://github.com/hirokisan/pagepath
github go golang matcher page path
Last synced: 2 months ago
JSON representation
Golang library for handling and matching page paths
- Host: GitHub
- URL: https://github.com/hirokisan/pagepath
- Owner: hirokisan
- License: mit
- Created: 2023-05-23T11:54:30.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-27T11:38:39.000Z (about 2 years ago)
- Last Synced: 2024-05-05T15:20:30.029Z (about 1 year ago)
- Topics: github, go, golang, matcher, page, path
- Language: Go
- Homepage: https://pkg.go.dev/github.com/hirokisan/pagepath
- Size: 12.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://goreportcard.com/report/github.com/hirokisan/pagepath)
[](https://github.com/hirokisan/pagepath/actions/workflows/golangci-lint.yml)
[](https://github.com/hirokisan/pagepath/actions/workflows/test.yml)# pagepath
`pagepath` is a Golang library for handling and matching page paths.
## Usage
Get element from page path
```go
import (
"fmt"
"log""github.com/hirokisan/pagepath"
)func main() {
pagePath := "https://pkg.go.dev/net/url?xxx=bbb#Parse"host, err := pagepath.Extract(pagePath, pagepath.ElementHost)
if err != nil {
log.Fatal(err)
}
fmt.Println(host) // pkg.go.dev
}
```Compare pages, for given elements
```go
import (
"fmt"
"log""github.com/hirokisan/pagepath"
)func main() {
matcher := pagepath.NewMatcher()page, err := pagepath.New("https://pkg.go.dev/net/url?xxx=bbb#Parse")
if err != nil {
log.Fatal(err)
}comparisonPage, err := pagepath.New("https://pkg.go.dev/net/url?xxx=bbb")
if err != nil {
log.Fatal(err)
}fmt.Println(matcher.Compare(page, comparisonPage, pagepath.ElementPath)) // true
}
```