1
0
Fork 0
mirror of https://github.com/actions/setup-python.git synced 2024-11-27 02:27:09 +00:00
setup-python/node_modules/resolve-url/resolve-url.js

48 lines
1 KiB
JavaScript
Raw Normal View History

2019-06-27 01:12:00 +00:00
// Copyright 2014 Simon Lydell
// X11 (“MIT”) Licensed. (See LICENSE.)
void (function(root, factory) {
if (typeof define === "function" && define.amd) {
define(factory)
} else if (typeof exports === "object") {
module.exports = factory()
} else {
root.resolveUrl = factory()
}
}(this, function() {
function resolveUrl(/* ...urls */) {
var numUrls = arguments.length
if (numUrls === 0) {
throw new Error("resolveUrl requires at least one argument; got none.")
}
var base = document.createElement("base")
base.href = arguments[0]
if (numUrls === 1) {
return base.href
}
var head = document.getElementsByTagName("head")[0]
head.insertBefore(base, head.firstChild)
var a = document.createElement("a")
var resolved
for (var index = 1; index < numUrls; index++) {
a.href = arguments[index]
resolved = a.href
base.href = resolved
}
head.removeChild(base)
return resolved
}
return resolveUrl
}));