// appendBaseHostToPath will add the base host to a relative url urlStr.
//
// A urlStr like "/trending" will be returned as https://github.com/trending
495047
func (t *Trending) appendBaseHostToPath(urlStr string, exists bool) *url.URL {
	if exists == false {
		return nil
	}

	rel, err := url.Parse(urlStr)
	if err != nil {
		return nil
	}

	return t.BaseURL.ResolveReference(rel)
}
884398
func (o *PetUpdateURL) WithBasePath(bp string) *PetUpdateURL {
	o.SetBasePath(bp)
	return o
}
13334
func formatBaseURL(baseURL string) string {
	if baseURL == "" {
		return ""
	}

	// remove last slash, so the API can append the path with ease.
	if baseURL[len(baseURL)-1] == '/' {
		baseURL = baseURL[0 : len(baseURL)-1]
	}

	portIdx := strings.LastIndexByte(baseURL, ':')

	schemaIdx := strings.Index(baseURL, "://")
	hasSchema := schemaIdx >= 0
	hasPort := portIdx > schemaIdx+1

	var port = "80"
	if hasPort {
		port = baseURL[portIdx+1:]
	}

	// find the schema based on the port.
	if !hasSchema {
		if port == "443" {
			baseURL = "https://" + baseURL
		} else {
			baseURL = "http://" + baseURL
		}
	} else if !hasPort {
		// has schema but not port.
		if strings.HasPrefix(baseURL, "https://") {
			port = "443"
		}
	}

	// finally, append the port part if it wasn't there.
	if !hasPort {
		baseURL += ":" + port
	}

	return baseURL
}
702525
func (s *BasePathMapping) SetBasePath(v string) *BasePathMapping {
	s.BasePath = &v
	return s
}
289035
func (o *GetGreetingURL) WithBasePath(bp string) *GetGreetingURL {
	o.SetBasePath(bp)
	return o
}
1250317
func (o *GetIdentityURL) WithBasePath(bp string) *GetIdentityURL {
	o.SetBasePath(bp)
	return o
}
1124149
func (o *UpdatePetWithFormURL) WithBasePath(bp string) *UpdatePetWithFormURL {
	o.SetBasePath(bp)
	return o
}
1204830
func (o *GetPetByIDURL) WithBasePath(bp string) *GetPetByIDURL {
	o.SetBasePath(bp)
	return o
}
336907
func (o *CreateUsersWithArrayInputURL) WithBasePath(bp string) *CreateUsersWithArrayInputURL {
	o.SetBasePath(bp)
	return o
}
374660
func (o *GetEndpointIDLabelsURL) WithBasePath(bp string) *GetEndpointIDLabelsURL {
	o.SetBasePath(bp)
	return o
}
954019
func OptionHostsPath(path string) SandboxOption {
	return func(sb *sandbox) {
		sb.config.hostsPath = path
	}
}
852118
func AddPath(paths ...string) {
	globalMu.Lock()
	globalPaths = append(globalPaths, paths...)
	globalMu.Unlock()
}
1274623
func (o *GetDebuginfoURL) WithBasePath(bp string) *GetDebuginfoURL {
	o.SetBasePath(bp)
	return o
}
1298864
func (ub *URLBuilder) BuildBaseURL() (string, error) {
	route := ub.cloneRoute(RouteNameBase)

	baseURL, err := route.URL()
	if err != nil {
		return "", err
	}

	return baseURL.String(), nil
}
1132576
func (p *Paths) GetBasePath(isRelativeURL bool) string {
	if isRelativeURL && p.CanonifyURLs {
		// The baseURL will be prepended later.
		return ""
	}
	return p.BasePath
}
292730
func (o *AddOneURL) WithBasePath(bp string) *AddOneURL {
	o.SetBasePath(bp)
	return o
}
366149
func (o *AddPetURL) WithBasePath(bp string) *AddPetURL {
	o.SetBasePath(bp)
	return o
}