Skip to content

Commit 67aaab6

Browse files
committed
Changed load_file to use urlparse
1 parent d7c33e8 commit 67aaab6

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

schema_enforcer/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import glob
66
from collections.abc import Mapping, Sequence
77
import importlib
8+
from urllib import parse as urlparse
89

910
from ruamel.yaml import YAML
1011
from ruamel.yaml.scalarstring import DoubleQuotedScalarString as DQ
@@ -374,10 +375,9 @@ def load_file(filename, file_type=None):
374375
if not file_type:
375376
file_type = "json" if filename.endswith(".json") else "yaml"
376377

377-
# When called from JsonRef, filename will contain a URI not just a local file,
378-
# but this function only handles local files. See jsonref.JsonLoader for a fuller implementation
379-
if filename.startswith("file:///"):
380-
filename = filename.replace("file://", "")
378+
# When called from JsonRef, filename will contain a file URI not just a local path
379+
if filename.startswith("file:"):
380+
filename = urlparse.urlparse(filename).path
381381

382382
handler = YAML_HANDLER if file_type == "yaml" else json
383383
with open(filename, "r", encoding="utf-8") as fileh:

0 commit comments

Comments
 (0)