// stripscheme removes any scheme components from url like paths.
509081
func stripscheme(path string) string {
	u, err := url.Parse(path)
	if err != nil {
		panic(err)
	}
	return u.Host + u.Path
}
774229
func APISchema(api *design.APIDefinition) *JSONSchema {
	api.IterateResources(func(r *design.ResourceDefinition) error {
		GenerateResourceDefinition(api, r)
		return nil
	})
	scheme := "http"
	if len(api.Schemes) > 0 {
		scheme = api.Schemes[0]
	}
	u := url.URL{Scheme: scheme, Host: api.Host}
	href := u.String()
	links := []*JSONLink{
		{
			Href: href,
			Rel:  "self",
		},
		{
			Href:   "/schema",
			Method: "GET",
			Rel:    "self",
			TargetSchema: &JSONSchema{
				Schema:               SchemaRef,
				AdditionalProperties: true,
			},
		},
	}
	s := JSONSchema{
		ID:          fmt.Sprintf("%s/schema", href),
		Title:       api.Title,
		Description: api.Description,
		Type:        JSONObject,
		Definitions: Definitions,
		Properties:  propertiesFromDefs(Definitions, "#/definitions/"),
		Links:       links,
	}
	return &s
}
763666
func (p Providers) ByScheme(scheme string) (Constructor, error) {
	for _, pp := range p {
		if pp.Provides(scheme) {
			return pp.New, nil
		}
	}
	return nil, fmt.Errorf("scheme %q not supported", scheme)
}
867352
func NewScheme() *Scheme {
	s := &Scheme{
		gvkToType:                 map[schema.GroupVersionKind]reflect.Type{},
		typeToGVK:                 map[reflect.Type][]schema.GroupVersionKind{},
		unversionedTypes:          map[reflect.Type]schema.GroupVersionKind{},
		unversionedKinds:          map[string]reflect.Type{},
		fieldLabelConversionFuncs: map[schema.GroupVersionKind]FieldLabelConversionFunc{},
		defaulterFuncs:            map[reflect.Type]func(interface{}){},
		versionPriority:           map[string][]string{},
		schemeName:                naming.GetNameFromCallsite(internalPackages...),
	}
	s.converter = conversion.NewConverter(s.nameFunc)

	utilruntime.Must(s.AddConversionFuncs(DefaultEmbeddedConversions()...))

	// Enable map[string][]string conversions by default
	utilruntime.Must(s.AddConversionFuncs(DefaultStringConversions...))
	utilruntime.Must(s.RegisterInputDefaults(&map[string][]string{}, JSONKeyMapper, conversion.AllowDifferentFieldTypeNames|conversion.IgnoreMissingFields))
	utilruntime.Must(s.RegisterInputDefaults(&url.Values{}, JSONKeyMapper, conversion.AllowDifferentFieldTypeNames|conversion.IgnoreMissingFields))
	return s
}
531323
func stripGopath(p string) string {
	for _, gopath := range gopaths() {
		p = strings.TrimPrefix(p, path.Join(gopath, "src")+"/")
	}
	return p
}
786154
func NewSchemer(driverName, username, password, host, port string) shimmie.Schemer {
	db := connect(driverName, username, password, host, port)
	return &schema{db}
}
141522
func (p *Policy) AllowURLSchemes(schemes ...string) *Policy {
	p.init()

	p.RequireParseableURLs(true)

	for _, scheme := range schemes {
		scheme = strings.ToLower(scheme)

		// Allow all URLs with matching scheme.
		p.allowURLSchemes[scheme] = nil
	}

	return p
}
804098
func NewScheme(internalGroupVersions ...unversioned.GroupVersion) *Scheme {
	s := &Scheme{conversion.NewScheme(), map[string]map[string]FieldLabelConversionFunc{}}

	for _, internalGV := range internalGroupVersions {
		s.raw.InternalVersions[internalGV.Group] = internalGV
	}

	s.raw.MetaFactory = conversion.SimpleMetaFactory{BaseFields: []string{"TypeMeta"}, VersionField: "APIVersion", KindField: "Kind"}
	if err := s.raw.AddConversionFuncs(
		s.embeddedObjectToRawExtension,
		s.rawExtensionToEmbeddedObject,
		s.runtimeObjectToRawExtensionArray,
		s.rawExtensionToRuntimeObjectArray,
	); err != nil {
		panic(err)
	}
	// Enable map[string][]string conversions by default
	if err := s.raw.AddConversionFuncs(DefaultStringConversions...); err != nil {
		panic(err)
	}
	if err := s.raw.RegisterInputDefaults(&map[string][]string{}, JSONKeyMapper, conversion.AllowDifferentFieldTypeNames|conversion.IgnoreMissingFields); err != nil {
		panic(err)
	}
	if err := s.raw.RegisterInputDefaults(&url.Values{}, JSONKeyMapper, conversion.AllowDifferentFieldTypeNames|conversion.IgnoreMissingFields); err != nil {
		panic(err)
	}
	return s
}
316275
func (p *Policy) AllowURLSchemeWithCustomPolicy(
	scheme string,
	urlPolicy func(url *url.URL) (allowUrl bool),
) *Policy {

	p.init()

	p.RequireParseableURLs(true)

	scheme = strings.ToLower(scheme)

	p.allowURLSchemes[scheme] = urlPolicy

	return p
}
376592
func stripBraces(str string) string {
	bs := []byte(str)
	const lb = byte('{')
	const rb = byte('}')
	start := 0
	for i := 0; i < len(bs); i++ {
		switch bs[i] {
		case lb:
			start = i + 1
		case rb:
			return `\$` + str[start:i]
		}
	}
	return str[start:]
}
258952
func string_strip(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) {
	var chars string
	if err := UnpackPositionalArgs(fnname, args, kwargs, 0, &chars); err != nil {
		return nil, err
	}
	recv := string(recv_.(String))
	var s string
	switch fnname[0] {
	case 's': // strip
		if chars != "" {
			s = strings.Trim(recv, chars)
		} else {
			s = strings.TrimSpace(recv)
		}
	case 'l': // lstrip
		if chars != "" {
			s = strings.TrimLeft(recv, chars)
		} else {
			s = strings.TrimLeftFunc(recv, unicode.IsSpace)
		}
	case 'r': // rstrip
		if chars != "" {
			s = strings.TrimRight(recv, chars)
		} else {
			s = strings.TrimRightFunc(recv, unicode.IsSpace)
		}
	}
	return String(s), nil
}
1201188
func (a *ActionDefinition) EffectiveSchemes() []string {
	// Compute the schemes
	schemes := a.Schemes
	if len(schemes) == 0 {
		res := a.Parent
		schemes = res.Schemes
		parent := res.Parent()
		for len(schemes) == 0 && parent != nil {
			schemes = parent.Schemes
			parent = parent.Parent()
		}
		if len(schemes) == 0 {
			schemes = Design.Schemes
		}
	}
	return schemes
}
769268
func stripPathShortcuts(p string) string {
	newPath := path.Clean(p)
	trimmed := strings.TrimPrefix(newPath, "../")

	for trimmed != newPath {
		newPath = trimmed
		trimmed = strings.TrimPrefix(newPath, "../")
	}

	// trim leftover {".", ".."}
	if newPath == "." || newPath == ".." {
		newPath = ""
	}

	if len(newPath) > 0 && string(newPath[0]) == "/" {
		return newPath[1:]
	}

	return newPath
}
123
func (s *Schema) refToSchema(str string, rootSchema Schema, loadExternal bool) (*Schema, error) {
	parentURL, err := url.Parse(s.parentId)
	if err == nil && parentURL.IsAbs() {
		sURL, err := url.Parse(str)
		if err == nil && !sURL.IsAbs() && !strings.HasPrefix(str, "#") {
			str = parentURL.ResolveReference(sURL).String()
		}
	}

	var split []string
	url, err := url.Parse(str)
	cacheKey, cacheKeyErr := resolveCacheKey(str)
	if err == nil && cacheKeyErr == nil {
		cachedSchema, ok := rootSchema.Cache[cacheKey]
		if ok {
			rootSchema = *cachedSchema
		} else {
			// Handle external URIs.
			if !loadExternal {
				return new(Schema), errors.New("external schemas are disabled")
			}
			resp, err := http.Get(str)
			if err != nil {
				return new(Schema), errors.New("bad external url")
			}
			defer resp.Body.Close()
			s, err := ParseWithCache(resp.Body, loadExternal, &rootSchema.Cache)
			if err != nil {
				return new(Schema), errors.New("error parsing external doc")
			}
			rootSchema.Cache[cacheKey] = s
			rootSchema = *s
		}
		str = url.Fragment
	}

	// Remove the prefix from internal URIs.
	str = strings.TrimPrefix(str, "#")
	str = strings.TrimPrefix(str, "/")

	split = strings.Split(str, "/")
	// Make replacements.
	for i, v := range split {
		r := strings.NewReplacer("~0", "~", "~1", "/", "%25", "%")
		split[i] = r.Replace(v)
	}
	// Resolve the local part of the URI.
	return resolveLocalPath(split, rootSchema, str)
}
1353214
func (s *DefineAnalysisSchemeInput) SetAnalysisScheme(v *AnalysisScheme) *DefineAnalysisSchemeInput {
	s.AnalysisScheme = v
	return s
}
1029710
func (r *ResponseMatcher) Scheme(scheme string) *ResponseMatcher {
	r.mux.mu.Lock()
	defer r.mux.mu.Unlock()
	r.scheme = scheme
	return r
}
1333387
func ByScheme(scheme string, settings environment.EnvSettings) (Provider, error) {
	// Q: What do you call a scheme string who's the boss?
	// A: Bruce Schemestring, of course.
	a := All(settings)
	for _, p := range a {
		if p.Provides(scheme) {
			return p, nil
		}
	}
	return Provider{}, fmt.Errorf("scheme %q not supported", scheme)
}