examples/template_stealjs/steal/steal.js
function( url, expand ) {
			var u = File(url);
			
			// if this.path is absolutely referenced
			if ( this.protocol() ) { //if we are absolutely referenced
				
				//try to shorten the path as much as possible:
				var firstDomain = this.domain(),
					secondDomain = u.domain();
				
				// if domains are equal, shorten
				if ( firstDomain && firstDomain == secondDomain ) {
					
					return this.toReferenceFromSameDomain(url);
				} else {
					// if there is no domain or not equal, use our path
					return this.path;
				}
			
			// the path is the same as the folder the page is in
			} else if ( url === steal.pageUrl().dir() && !expand ) {

				return this.path;

			} else if ( this.isLocalAbsolute() ) { // we are a path like /page.js

				return (u.domain() ? u.protocol() + "//" + u.domain() : "" )+ this.path;
				
			} else  { //we have 2 relative paths, remove folders with every ../
				
				if ( url === '' ) {
					return this.path.replace(/\/$/, '');
				}
				
				var urls = url.split('/'),
					paths = this.path.split('/'),
					path = paths[0];
				
				//if we are joining from a folder like cookbook/, remove the last empty part
				if ( url.match(/\/$/) ) {
					urls.pop();
				}
				// for each .. remove one folder
				while ( path == '..' && paths.length > 0 ) {
					// if we've emptied out, folders, just break
					// leaving any additional ../s
					if(! urls.pop() ){ 
						break;
					}
					paths.shift();
					
					path = paths[0];
				}
				return urls.concat(paths).join('/');
			}
		}
function( url, expand ) {
			var u = File(url);
			
			// if this.path is absolutely referenced
			if ( this.protocol() ) { //if we are absolutely referenced
				
				//try to shorten the path as much as possible:
				var firstDomain = this.domain(),
					secondDomain = u.domain();
				
				// if domains are equal, shorten
				if ( firstDomain && firstDomain == secondDomain ) {
					
					return this.toReferenceFromSameDomain(url);
				} else {
					// if there is no domain or not equal, use our path
					return this.path;
				}
			
			// the path is the same as the folder the page is in
			} else if ( url === steal.pageUrl().dir() && !expand ) {

				return this.path;

			} else if ( this.isLocalAbsolute() ) { // we are a path like /page.js

				return (u.domain() ? u.protocol() + "//" + u.domain() : "" )+ this.path;
				
			} else  { //we have 2 relative paths, remove folders with every ../
				
				if ( url === '' ) {
					return this.path.replace(/\/$/, '');
				}
				
				var urls = url.split('/'),
					paths = this.path.split('/'),
					path = paths[0];
				
				//if we are joining from a folder like cookbook/, remove the last empty part
				if ( url.match(/\/$/) ) {
					urls.pop();
				}
				// for each .. remove one folder
				while ( path == '..' && paths.length > 0 ) {
					// if we've emptied out, folders, just break
					// leaving any additional ../s
					if(! urls.pop() ){ 
						break;
					}
					paths.shift();
					
					path = paths[0];
				}
				return urls.concat(paths).join('/');
			}
		}
function ( url , expand ) { var u = File ( url ) ; // if this.path is absolutely referenced if ( this . protocol ( ) ) { //if we are absolutely referenced //try to shorten the path as much as possible: var firstDomain = this . domain ( ) , secondDomain = u . domain ( ) ; // if domains are equal, shorten if ( firstDomain && firstDomain == secondDomain ) { return this . toReferenceFromSameDomain ( url ) ; } else { // if there is no domain or not equal, use our path return this . path ; } // the path is the same as the folder the page is in } else if ( url === steal . pageUrl ( ) . dir ( ) && ! expand ) { return this . path ; } else if ( this . isLocalAbsolute ( ) ) { // we are a path like /page.js return ( u . domain ( ) ? u . protocol ( ) + "//" + u . domain ( ) : "" ) + this . path ; } else { //we have 2 relative paths, remove folders with every ../ if ( url === '' ) { return this . path . replace ( / \/$ / , '' ) ; } var urls = url . split ( '/' ) , paths = this . path . split ( '/' ) , path = paths [ 0 ] ; //if we are joining from a folder like cookbook/, remove the last empty part if ( url . match ( / \/$ / ) ) { urls . pop ( ) ; } // for each .. remove one folder while ( path == '..' && paths . length > 0 ) { // if we've emptied out, folders, just break // leaving any additional ../s if ( ! urls . pop ( ) ) { break ; } paths . shift ( ) ; path = paths [ 0 ] ; } return urls . concat ( paths ) . join ( '/' ) ; } }
Returns the path of this file referenced from another url or path.

new steal.File('a/b.c').joinFrom('/d/e')//-> /d/e/a/b.c

@param {String} url
@param {Boolean} expand if the path should be expanded
@return {String}
Returns the path of this file referenced from another url or path .