mirror of
https://github.com/hanzoai/oxy.git
synced 2026-09-30 23:42:31 +00:00
Co-authored-by: Tom Moulard <[email protected]> Co-authored-by: M <[email protected]> Co-authored-by: Sylvain Rabot <[email protected]>
30 lines
512 B
Go
30 lines
512 B
Go
package stickycookie
|
|
|
|
import (
|
|
"net/url"
|
|
)
|
|
|
|
// RawValue is a no-op that returns the raw strings as-is.
|
|
type RawValue struct{}
|
|
|
|
// Get returns the raw value.
|
|
func (v *RawValue) Get(raw *url.URL) string {
|
|
return raw.String()
|
|
}
|
|
|
|
// FindURL gets url from array that match the value.
|
|
func (v *RawValue) FindURL(raw string, urls []*url.URL) (*url.URL, error) {
|
|
for _, u := range urls {
|
|
ok, err := areURLEqual(raw, u)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if ok {
|
|
return u, nil
|
|
}
|
|
}
|
|
|
|
return nil, nil
|
|
}
|