lib/require.js
function(url, base) {
			if (!url || url.indexOf('://') !== -1) { return url; }

			var anchor = document.createElement('a');
			anchor.href = (base || location.href);

			var protocol	= anchor.protocol + '//',
				host		= anchor.host,
				path		= anchor.pathname,
				parts		= filter(path.split('/'), function(part) { return part !== ''; });

			each(url.replace(/\?.*/, '').split('/'), function(part, index) {
				switch(part) {
					case '..':
						if (!parts.length) {
							throw new Error('Path outside of root: ' + url);
						}
						parts.length--;
						break;
					case '.':	break;
					default:	parts.push(part); break
				}
			});
			return protocol + host + '/' + parts.join('/');
		}
function(url, base) {
			if (!url || url.indexOf('://') !== -1) { return url; }

			var anchor = document.createElement('a');
			anchor.href = (base || location.href);

			var protocol	= anchor.protocol + '//',
				host		= anchor.host,
				path		= anchor.pathname,
				parts		= filter(path.split('/'), function(part) { return part !== ''; });

			each(url.replace(/\?.*/, '').split('/'), function(part, index) {
				switch(part) {
					case '..':
						if (!parts.length) {
							throw new Error('Path outside of root: ' + url);
						}
						parts.length--;
						break;
					case '.':	break;
					default:	parts.push(part); break
				}
			});
			return protocol + host + '/' + parts.join('/');
		}
function ( url , base ) { if ( ! url || url . indexOf ( '://' ) !== - 1 ) { return url ; } var anchor = document . createElement ( 'a' ) ; anchor . href = ( base || location . href ) ; var protocol = anchor . protocol + '//' , host = anchor . host , path = anchor . pathname , parts = filter ( path . split ( '/' ) , function ( part ) { return part !== '' ; } ) ; each ( url . replace ( / \?.* / , '' ) . split ( '/' ) , function ( part , index ) { switch ( part ) { case '..' : if ( ! parts . length ) { throw new Error ( 'Path outside of root: ' + url ) ; } parts . length -- ; break ; case '.' : break ; default : parts . push ( part ) ; break } } ) ; return protocol + host + '/' + parts . join ( '/' ) ; }
Convert a relative url to an absolute, relative to the `base` url specified.
Convert a relative url to an absolute relative to the base url specified .