func Parse(text string) (*URL, error) {
	schemeStartIndex := 0
	schemeEndIndex := strings.Index(text, "://")
	if schemeEndIndex <= 0 {
		return nil, errors.New("url has no scheme or authority: " + text)
	}
	scheme := text[schemeStartIndex:schemeEndIndex]
	authorityStartIndex := schemeEndIndex + 3                                                     // ignore ://
	authorityEndIndex := authorityStartIndex + strings.IndexAny(text[authorityStartIndex:], "/?") // ends at path/query start
	if authorityStartIndex > authorityEndIndex {                                                  // no path/query
		authorityEndIndex = len(text)
	}
	authority := text[authorityStartIndex:authorityEndIndex]
	pathStartIndex := authorityEndIndex
	pathEndIndex := pathStartIndex + strings.Index(text[pathStartIndex:], "?")
	if pathStartIndex > pathEndIndex { // no path
		pathEndIndex = len(text)
	}
	path := text[pathStartIndex:pathEndIndex]
	queryStartIndex := pathEndIndex + 1 // ignore ?
	if queryStartIndex > len(text) {    // no query
		queryStartIndex = len(text)
	}
	rawQuery := text[queryStartIndex:]
	fragmentIndex := strings.Index(rawQuery, "#")
	if fragmentIndex >= 0 {
		return nil, errors.New("url fragment not allowed: " + text)
	}
	u := URL{
		Scheme:    scheme,
		Authority: authority,
		Path:      path,
		RawQuery:  rawQuery,
	}
	return &u, nil
}
// Parse creates a URL out of the text.
Parse creates a URL out of the text.
// Parse creates a URL out of the text .
func Parse(text string) (*URL, error) {
	schemeStartIndex := 0
	schemeEndIndex := strings.Index(text, "://")
	if schemeEndIndex <= 0 {
		return nil, errors.New("url has no scheme or authority: " + text)
	}
	scheme := text[schemeStartIndex:schemeEndIndex]
	authorityStartIndex := schemeEndIndex + 3                                                     
	authorityEndIndex := authorityStartIndex + strings.IndexAny(text[authorityStartIndex:], "/?") 
	if authorityStartIndex > authorityEndIndex {                                                  
		authorityEndIndex = len(text)
	}
	authority := text[authorityStartIndex:authorityEndIndex]
	pathStartIndex := authorityEndIndex
	pathEndIndex := pathStartIndex + strings.Index(text[pathStartIndex:], "?")
	if pathStartIndex > pathEndIndex { 
		pathEndIndex = len(text)
	}
	path := text[pathStartIndex:pathEndIndex]
	queryStartIndex := pathEndIndex + 1 
	if queryStartIndex > len(text) {    
		queryStartIndex = len(text)
	}
	rawQuery := text[queryStartIndex:]
	fragmentIndex := strings.Index(rawQuery, "#")
	if fragmentIndex >= 0 {
		return nil, errors.New("url fragment not allowed: " + text)
	}
	u := URL{
		Scheme:    scheme,
		Authority: authority,
		Path:      path,
		RawQuery:  rawQuery,
	}
	return &u, nil
}
func Parse ( text string ) ( * URL , error ) { schemeStartIndex := 0 schemeEndIndex := strings . Index ( text , " " ) if schemeEndIndex <= 0 { return nil , errors . New ( " " + text ) } scheme := text [ schemeStartIndex : schemeEndIndex ] authorityStartIndex := schemeEndIndex + 3 authorityEndIndex := authorityStartIndex + strings . IndexAny ( text [ authorityStartIndex : ] , " " ) if authorityStartIndex > authorityEndIndex { authorityEndIndex = len ( text ) } authority := text [ authorityStartIndex : authorityEndIndex ] pathStartIndex := authorityEndIndex pathEndIndex := pathStartIndex + strings . Index ( text [ pathStartIndex : ] , " " ) if pathStartIndex > pathEndIndex { pathEndIndex = len ( text ) } path := text [ pathStartIndex : pathEndIndex ] queryStartIndex := pathEndIndex + 1 if queryStartIndex > len ( text ) { queryStartIndex = len ( text ) } rawQuery := text [ queryStartIndex : ] fragmentIndex := strings . Index ( rawQuery , " " ) if fragmentIndex >= 0 { return nil , errors . New ( " " + text ) } u := URL { Scheme : scheme , Authority : authority , Path : path , RawQuery : rawQuery , } return & u , nil }
Parse creates a URL out of the text.
Parse creates a URL out of the text .
// ignore :// // ends at path/query start // no path/query // no path // ignore ? // no query