Commit 5c7e7eaf authored by Boris Kocherov's avatar Boris Kocherov

remove duplicate base_url composition

parent 61e2a609
...@@ -22,8 +22,14 @@ ...@@ -22,8 +22,14 @@
return base_url; return base_url;
} }
function getJSON(url) { function getJSON(url, base_url) {
var protocol = URI(url).protocol(); var protocol = URI(url).protocol();
if (protocol === "") {
if (base_url && !url.startsWith("/")) {
url = base_url + "/" + url;
protocol = URI(url).protocol();
}
}
if (protocol === "http" || protocol === "https") { if (protocol === "http" || protocol === "https") {
if (URI(window.location).protocol() !== protocol) { if (URI(window.location).protocol() !== protocol) {
throw new Error("You cannot mixed http and https calls"); throw new Error("You cannot mixed http and https calls");
...@@ -71,14 +77,7 @@ ...@@ -71,14 +77,7 @@
}); });
} }
return RSVP.Queue().push(function () { return getJSON(ref, base_url)
if (URI(ref).protocol() === "") {
if (base_url && !ref.startsWith("/")) {
ref = base_url + "/" + ref;
}
}
return getJSON(ref);
})
.push(function (external_schema) { .push(function (external_schema) {
parts = ref.split("#"); parts = ref.split("#");
ref = "#" + parts[1]; ref = "#" + parts[1];
...@@ -227,7 +226,7 @@ ...@@ -227,7 +226,7 @@
.push(function (json_object) { .push(function (json_object) {
var parameter_schema_url, var parameter_schema_url,
st, st,
base_url; base_url = getBaseUrl(schema_url);
for (st in json_object["software-type"]) { for (st in json_object["software-type"]) {
if (json_object["software-type"].hasOwnProperty(st)) { if (json_object["software-type"].hasOwnProperty(st)) {
...@@ -237,14 +236,7 @@ ...@@ -237,14 +236,7 @@
} }
} }
if (URI(parameter_schema_url).protocol() === "") { return getJSON(parameter_schema_url, base_url)
base_url = getBaseUrl(schema_url);
if (base_url !== undefined) {
parameter_schema_url = base_url + "/" + parameter_schema_url;
}
}
return getJSON(parameter_schema_url)
.push(function (schema) { .push(function (schema) {
return expandSchema(schema, schema, base_url) return expandSchema(schema, schema, base_url)
.push(function (loaded_json) { .push(function (loaded_json) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment