Skip to content

Commit

Permalink
encode base url the safe way (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
lintax authored Apr 2, 2019
1 parent 3d79e3c commit 2371202
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion oksdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,18 @@
function getRemoteUrl(sources, fallback) {
for (var i = 0; i < sources.length; i++) {
var source = sources[i];
if (source && (source.startsWith("http://") || source.startsWith("https://"))) return source;
if (source && (source.startsWith("http://") || source.startsWith("https://"))) return getBaseUrl(source);
}
return fallback;
}

function getBaseUrl(stringUrl) {
// URL() not supported for Android < 4.4
var url = document.createElement('a');
url.setAttribute('href', stringUrl);
return url.protocol + "//" + url.hostname + "/"
}

function invokeUIMethod() {
var argStr = "";
for (var i = 0; i < arguments.length; i++) {
Expand Down

0 comments on commit 2371202

Please sign in to comment.