mirror of
https://github.com/systemjs/systemjs.git
synced 2026-01-18 14:53:14 +00:00
71 lines
2.4 KiB
JavaScript
71 lines
2.4 KiB
JavaScript
(function($__global) {
|
|
|
|
$__global.upgradeSystemLoader = function() {
|
|
$__global.upgradeSystemLoader = undefined;
|
|
|
|
// indexOf polyfill for IE
|
|
var indexOf = Array.prototype.indexOf || function(item) {
|
|
for (var i = 0, l = this.length; i < l; i++)
|
|
if (this[i] === item)
|
|
return i;
|
|
return -1;
|
|
}
|
|
|
|
// Absolute URL parsing, from https://gist.github.com/Yaffle/1088850
|
|
function parseURI(url) {
|
|
var m = String(url).replace(/^\s+|\s+$/g, '').match(/^([^:\/?#]+:)?(\/\/(?:[^:@\/?#]*(?::[^:@\/?#]*)?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);
|
|
// authority = '//' + user + ':' + pass '@' + hostname + ':' port
|
|
return (m ? {
|
|
href : m[0] || '',
|
|
protocol : m[1] || '',
|
|
authority: m[2] || '',
|
|
host : m[3] || '',
|
|
hostname : m[4] || '',
|
|
port : m[5] || '',
|
|
pathname : m[6] || '',
|
|
search : m[7] || '',
|
|
hash : m[8] || ''
|
|
} : null);
|
|
}
|
|
function toAbsoluteURL(base, href) {
|
|
function removeDotSegments(input) {
|
|
var output = [];
|
|
input.replace(/^(\.\.?(\/|$))+/, '')
|
|
.replace(/\/(\.(\/|$))+/g, '/')
|
|
.replace(/\/\.\.$/, '/../')
|
|
.replace(/\/?[^\/]*/g, function (p) {
|
|
if (p === '/..')
|
|
output.pop();
|
|
else
|
|
output.push(p);
|
|
});
|
|
return output.join('').replace(/^\//, input.charAt(0) === '/' ? '/' : '');
|
|
}
|
|
|
|
href = parseURI(href || '');
|
|
base = parseURI(base || '');
|
|
|
|
return !href || !base ? null : (href.protocol || base.protocol) +
|
|
(href.protocol || href.authority ? href.authority : base.authority) +
|
|
removeDotSegments(href.protocol || href.authority || href.pathname.charAt(0) === '/' ? href.pathname : (href.pathname ? ((base.authority && !base.pathname ? '/' : '') + base.pathname.slice(0, base.pathname.lastIndexOf('/') + 1) + href.pathname) : base.pathname)) +
|
|
(href.protocol || href.authority || href.pathname ? href.search : (href.search || base.search)) +
|
|
href.hash;
|
|
}
|
|
|
|
// clone the original System loader
|
|
var System;
|
|
(function() {
|
|
var originalSystem = $__global.System;
|
|
System = $__global.System = new LoaderPolyfill(originalSystem);
|
|
System.baseURL = originalSystem.baseURL;
|
|
System.paths = { '*': '*.js' };
|
|
System.originalSystem = originalSystem;
|
|
})();
|
|
|
|
System.noConflict = function() {
|
|
$__global.SystemJS = System;
|
|
$__global.System = System.originalSystem;
|
|
}
|
|
|
|
|