Create a clean domain-relative URL form a docuetn URL
553672
protected function buildUrl($url)
    {
        return Controller::join_links(
            Director::baseURL(),
            Config::inst()->get('DocumentationViewer', 'link_base'),
            $url,
            '/'
        );
    }
2220
def clean_url(url, replacement='_'):
        
        cleaned = re.sub(r'/$', '', re.sub(r'https?://', '', url))
        for character in '/ _ ? & : ; %'.split():
            cleaned = cleaned.replace(character, replacement)
        return cleaned
292349
def clean_url(url, force_scheme=None):
    """"""
    # URL should be ASCII according to RFC 3986
    url = str(url)
    # Collapse ../../ and related
    url_parts = urlparse.urlparse(url)
    path_parts = []
    for part in url_parts.path.split('/'):
        if part == '.':
            continue
        elif part == '..':
            if path_parts:
                path_parts.pop()
        else:
            path_parts.append(part)

    url_parts = list(url_parts)
    if force_scheme:
        url_parts[0] = force_scheme
    url_parts[2] = '/'.join(path_parts)

    if FLAGS.keep_query_string == False:
        url_parts[4] = ''    # No query string

    url_parts[5] = ''    # No path

    # Always have a trailing slash
    if not url_parts[2]:
        url_parts[2] = '/'

    return urlparse.urlunparse(url_parts)
457922
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('/');
		}
298552
function formatURL(httpsOptions) {
  var url;
  if (httpsOptions.protocol) {
    url = httpsOptions.protocol;
  } else {
    url = 'https:';
  }
  url += '//';
  if (httpsOptions.auth) {
    url += httpsOptions.auth + '@';
  }
  if (httpsOptions.host) {
    url += httpsOptions.host;
  } else if (httpsOptions.hostname) {
    url += httpsOptions.hostname;
  } else {
    url += 'localhost';
  }
  if (httpsOptions.port && !url.includes(':' + httpsOptions.port)) {
    url += ':' + httpsOptions.port;
  }
  if (httpsOptions.path) {
    url += httpsOptions.path;
  } else {
    url += '/';
  }
  return url;
}
1019720
function resolve(baseUri, relativeUri) {
  // there are several kinds of relative urls:
  // 1. //foo - replaces everything from the domain on.  foo is a domain name
  // 2. foo - replaces the last part of the path, the whole query and fragment
  // 3. /foo - replaces the the path, the query and fragment
  // 4. ?foo - replace the query and fragment
  // 5. #foo - replace the fragment only

  var absoluteUri = baseUri.clone();
  // we satisfy these conditions by looking for the first part of relativeUri
  // that is not blank and applying defaults to the rest

  var overridden = relativeUri.hasScheme();

  if (overridden) {
    absoluteUri.setRawScheme(relativeUri.getRawScheme());
  } else {
    overridden = relativeUri.hasCredentials();
  }

  if (overridden) {
    absoluteUri.setRawCredentials(relativeUri.getRawCredentials());
  } else {
    overridden = relativeUri.hasDomain();
  }

  if (overridden) {
    absoluteUri.setRawDomain(relativeUri.getRawDomain());
  } else {
    overridden = relativeUri.hasPort();
  }

  var rawPath = relativeUri.getRawPath();
  var simplifiedPath = collapse_dots(rawPath);
  if (overridden) {
    absoluteUri.setPort(relativeUri.getPort());
    simplifiedPath = simplifiedPath
        && simplifiedPath.replace(EXTRA_PARENT_PATHS_RE, '');
  } else {
    overridden = !!rawPath;
    if (overridden) {
      // resolve path properly
      if (simplifiedPath.charCodeAt(0) !== 0x2f /* / */) {  // path is relative
        var absRawPath = collapse_dots(absoluteUri.getRawPath() || '')
            .replace(EXTRA_PARENT_PATHS_RE, '');
        var slash = absRawPath.lastIndexOf('/') + 1;
        simplifiedPath = collapse_dots(
            (slash ? absRawPath.substring(0, slash) : '')
            + collapse_dots(rawPath))
            .replace(EXTRA_PARENT_PATHS_RE, '');
      }
    } else {
      simplifiedPath = simplifiedPath
          && simplifiedPath.replace(EXTRA_PARENT_PATHS_RE, '');
      if (simplifiedPath !== rawPath) {
        absoluteUri.setRawPath(simplifiedPath);
      }
    }
  }

  if (overridden) {
    absoluteUri.setRawPath(simplifiedPath);
  } else {
    overridden = relativeUri.hasQuery();
  }

  if (overridden) {
    absoluteUri.setRawQuery(relativeUri.getRawQuery());
  } else {
    overridden = relativeUri.hasFragment();
  }

  if (overridden) {
    absoluteUri.setRawFragment(relativeUri.getRawFragment());
  }

  return absoluteUri;
}
682891
function absoluteUrl (baseUrl, pathUrl) {
  if (pathUrl && pathUrl.slice(0, 4) !== 'http') {
    return [baseUrl, pathUrl].map((path) => {
      if (path[0] === '/') {
        path = path.slice(1)
      }
      if (path[path.length - 1] === '/') {
        path = path.slice(0, path.length - 1)
      }
      return path
    }).join('/')
  }

  return pathUrl
}
208571
def create(server_context, domain_definition, container_path=None):
    # type: (ServerContext, dict, str) -> Domain
    
    url = server_context.build_url('property', 'createDomain.api', container_path=container_path)

    headers = {
        'Content-Type': 'application/json'
    }

    domain = None

    raw_domain = server_context.make_request(url, json_dumps(domain_definition), headers=headers)

    if raw_domain is not None:
        domain = Domain.from_data(raw_domain)

    return domain
765333
def create(cls, domain, tlp_level=0, tags=[]):
        
        return cls._create(domain=domain, tlp_level=tlp_level, tags=tags)
1104539
def url2domain(url):
    
    parsed_uri = urlparse.urlparse(url)
    domain = '{uri.netloc}'.format(uri=parsed_uri)
    domain = re.sub("^.+@", "", domain)
    domain = re.sub(":.+$", "", domain)
    return domain
799449
function BuildHttpPath(root, path) {
    var httpPath = (root + path).replace(/\/\//g, "/");
    if(httpPath[0] !== '/') {
      httpPath = "/" + httpPath;
    }
    if(httpPath !== "/" && httpPath.charAt(httpPath.length-1) === "/") {
      return httpPath.substr(0, httpPath.length-1);
    }
    // We allow a single back-level in the HTTP route creation (api/domain../domains becoms api/domains)
    if(path.indexOf('..') === 0) {
      var split = httpPath.split('/'),
        newPath = '';
      for(var i=0; i < split.length; i++) {
        if(split[i] === '') continue;
        if(split[i].indexOf('..') !== -1 && typeof split[i] === 'string') {
          split[i] = split[i+1];
          split[i+1] = '';
        }
        newPath += '/' + split[i];
      }
      httpPath = newPath;
    }
    return httpPath;
  }
229675
def get_absolute_url(self, domain=False):
        "  "
        category = self.category

        kwargs = {
            'slug': self.slug,
        }

        if self.static:
            kwargs['id'] = self.pk
            if category.tree_parent_id:
                kwargs['category'] = category.tree_path
                url = reverse('static_detail', kwargs=kwargs)
            else:
                url = reverse('home_static_detail', kwargs=kwargs)
        else:
            publish_from = localize(self.publish_from)
            kwargs.update({
                    'year': publish_from.year,
                    'month': publish_from.month,
                    'day': publish_from.day,
                })
            if category.tree_parent_id:
                kwargs['category'] = category.tree_path
                url = reverse('object_detail', kwargs=kwargs)
            else:
                url = reverse('home_object_detail', kwargs=kwargs)

        if category.site_id != settings.SITE_ID or domain:
            return 'http://' + category.site.domain + url
        return url
1231009
def clean_link(self, url):
        """"""
        return self._clean_re.sub(lambda match: "%%%2x" % ord(match.group(0)), url)
262901
public function cleanUrlHandler(): void
    {
        global $pretext;

        $basename = explode('?', (string) $pretext['request_uri']);
        $basename = basename(array_shift($basename));

        if ($basename === 'robots.txt') {
            $this->sendRobots();
        }

        if ($basename === 'sitemap.xml' || $basename === 'sitemap.xml.gz') {
            $this->populateArticleFields()->sendSitemap();
        }
    }
766284
function cleanRoot() {
	var location = LOCATION(),
		domain = location.protocol + "//" + location.host,
		// pulls root from route.urlData
		root = bindingProxy.call("root"),
		index = root.indexOf(domain);

	if (index === 0) {
		return root.substr(domain.length);
	}
	return root;
}
408653
def create_domain(self, domain_name):
        
        params = {'DomainName':domain_name}
        d = self.get_object('CreateDomain', params, Domain)
        d.name = domain_name
        return d
1146392
function prettyUrl(file) {
  file.extname = ".html";

  if (file.basename !== "index") {
    file.dirname = path.join(file.dirname, file.basename);
    file.basename = "index";
  }

  return file;
}