Skip to content

Commit e47fcda

Browse files
committed
Move pathURI() to the schema package
I don't foresee any need for this function outside the `schema` package, so it doesn't seem necessary to export it.
1 parent 14fa848 commit e47fcda

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

Diff for: check/checkdata/schema/schema.go

+15-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
package schema
33

44
import (
5+
"net/url"
56
"os"
7+
"path/filepath"
68
"regexp"
79

8-
"github.com/arduino/arduino-check/util"
910
"github.com/arduino/go-paths-helper"
1011
"github.com/xeipuuv/gojsonschema"
1112
)
@@ -23,7 +24,7 @@ func Compile(schemaFilename string, referencedSchemaFilenames []string, schemasP
2324
// Load the referenced schemas.
2425
for _, referencedSchemaFilename := range referencedSchemaFilenames {
2526
referencedSchemaPath := schemasPath.Join(referencedSchemaFilename)
26-
referencedSchemaURI := util.PathURI(referencedSchemaPath)
27+
referencedSchemaURI := pathURI(referencedSchemaPath)
2728
err := schemaLoader.AddSchemas(gojsonschema.NewReferenceLoader(referencedSchemaURI))
2829
if err != nil {
2930
panic(err.Error())
@@ -32,7 +33,7 @@ func Compile(schemaFilename string, referencedSchemaFilenames []string, schemasP
3233

3334
// Compile the schema.
3435
schemaPath := schemasPath.Join(schemaFilename)
35-
schemaURI := util.PathURI(schemaPath)
36+
schemaURI := pathURI(schemaPath)
3637
compiledSchema, err := schemaLoader.Compile(gojsonschema.NewReferenceLoader(schemaURI))
3738
if err != nil {
3839
panic(err.Error())
@@ -78,3 +79,14 @@ func ValidationErrorMatch(typeQuery string, fieldQuery string, descriptionQueryR
7879

7980
return false
8081
}
82+
83+
// pathURI returns the URI representation of the path argument.
84+
func pathURI(path *paths.Path) string {
85+
uriFriendlyPath := filepath.ToSlash(path.String())
86+
pathURI := url.URL{
87+
Scheme: "file",
88+
Path: uriFriendlyPath,
89+
}
90+
91+
return pathURI.String()
92+
}

Diff for: util/util.go

-20
This file was deleted.

0 commit comments

Comments
 (0)