2
2
package schema
3
3
4
4
import (
5
+ "net/url"
5
6
"os"
7
+ "path/filepath"
6
8
"regexp"
7
9
8
- "github.com/arduino/arduino-check/util"
9
10
"github.com/arduino/go-paths-helper"
10
11
"github.com/xeipuuv/gojsonschema"
11
12
)
@@ -23,7 +24,7 @@ func Compile(schemaFilename string, referencedSchemaFilenames []string, schemasP
23
24
// Load the referenced schemas.
24
25
for _ , referencedSchemaFilename := range referencedSchemaFilenames {
25
26
referencedSchemaPath := schemasPath .Join (referencedSchemaFilename )
26
- referencedSchemaURI := util . PathURI (referencedSchemaPath )
27
+ referencedSchemaURI := pathURI (referencedSchemaPath )
27
28
err := schemaLoader .AddSchemas (gojsonschema .NewReferenceLoader (referencedSchemaURI ))
28
29
if err != nil {
29
30
panic (err .Error ())
@@ -32,7 +33,7 @@ func Compile(schemaFilename string, referencedSchemaFilenames []string, schemasP
32
33
33
34
// Compile the schema.
34
35
schemaPath := schemasPath .Join (schemaFilename )
35
- schemaURI := util . PathURI (schemaPath )
36
+ schemaURI := pathURI (schemaPath )
36
37
compiledSchema , err := schemaLoader .Compile (gojsonschema .NewReferenceLoader (schemaURI ))
37
38
if err != nil {
38
39
panic (err .Error ())
@@ -78,3 +79,14 @@ func ValidationErrorMatch(typeQuery string, fieldQuery string, descriptionQueryR
78
79
79
80
return false
80
81
}
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
+ }
0 commit comments