mirror of
https://github.com/datarhei/core.git
synced 2025-10-06 00:17:07 +08:00

Commits (Ingo Oppermann): - Add experimental SRT connection stats and logs - Hide /config/reload endpoint in reade-only mode - Add SRT server - Create v16 in go.mod - Fix data races, tests, lint, and update dependencies - Add trailing slash for routed directories (datarhei/restreamer#340) - Allow relative URLs in content in static routes Co-Authored-By: Ingo Oppermann <57445+ioppermann@users.noreply.github.com>
19 lines
534 B
Go
19 lines
534 B
Go
package jsonschema
|
|
|
|
import (
|
|
"regexp"
|
|
"strings"
|
|
)
|
|
|
|
var matchFirstCap = regexp.MustCompile("(.)([A-Z][a-z]+)")
|
|
var matchAllCap = regexp.MustCompile("([a-z0-9])([A-Z])")
|
|
|
|
// ToSnakeCase converts the provided string into snake case using dashes.
|
|
// This is useful for Schema IDs and definitions to be coherent with
|
|
// common JSON Schema examples.
|
|
func ToSnakeCase(str string) string {
|
|
snake := matchFirstCap.ReplaceAllString(str, "${1}-${2}")
|
|
snake = matchAllCap.ReplaceAllString(snake, "${1}-${2}")
|
|
return strings.ToLower(snake)
|
|
}
|