func (p *Path) URL() (u *url.URL) {
	return &url.URL{
		Scheme: p.Scheme,
		Host:   p.Host,
		Path:   p.Path,
	}
}
URL converts the path to a url.URL.
package adspath
import (
	"bytes"
	"errors"
	"net/url"
	"strings"
)
type Path struct {
	Scheme string
	Host string
	Path string
}
func Parse(rawpath string) (path *Path, err error) {
	var rest string
	if rawpath == "" {
		return nil, errors.New("empty path")
	}
	path = new(Path)
	if path.Scheme, rest, err = parseScheme(rawpath); err != nil {
		return nil, err
	}
	switch strings.ToLower(path.Scheme) {
	case "ldap":
		path.Scheme = LDAP
	case "winnt":
		path.Scheme = WinNT
	case "iis":
		path.Scheme = IIS
	case "gc":
		path.Scheme = GC
	}
	if rest == "" {
		return
	}
	if !strings.HasPrefix(rest, "//") {
		return nil, errors.New("Invalid ADS path")
	}
	rest = rest[2:]
	authority, rest := split(rest, "/")
	if rest == "" && path.Scheme == LDAP && strings.ContainsRune(authority, '=') {
		rest = authority
		authority = ""
	}
	path.Host, path.Path = authority, rest
	return
}
func parseScheme(rawpath string) (scheme, path string, err error) {
	for i := 0; i < len(rawpath); i++ {
		c := rawpath[i]
		switch {
		case 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z':
		case '0' <= c && c <= '9' || c == '+' || c == '-' || c == '.':
			if i == 0 {
				return "", rawpath, nil
			}
		case c == ':':
			if i == 0 {
				return "", "", errors.New("missing protocol scheme")
			}
			return rawpath[:i], rawpath[i+1:], nil
		default:
			return "", rawpath, nil
		}
	}
	return "", rawpath, nil
}
func split(input string, cut string) (string, string) {
	i := strings.Index(input, cut)
	if i < 0 {
		return input, ""
	}
	return input[:i], input[i+len(cut):]
}