Determine and set the canonical URL for the given record, for example: dev/docs/en/Path/To/Document
192374
public function populateCanonicalUrl()
    {
        $url = Director::absoluteURL(Controller::join_links(
            Config::inst()->get('DocumentationViewer', 'link_base'),
            $this->getEntity()->getLanguage(),
            $this->getRelativeLink()
        ));

        $this->setCanonicalUrl($url);
    }
616248
function pageDefaults() {
  return {
    path: canonicalPath(),
    referrer: document.referrer,
    search: location.search,
    title: document.title,
    url: canonicalUrl(location.search)
  };
}
733345
def build_url_query(current_path, datum = nil)
      unless datum.nil?
        current_path += '?'
        current_path += URI.encode_www_form datum
      end
      current_path
    end
306173
def path_to_url
      prefix = Jammit.asset_roots.map{ |path| Regexp.escape(path) }.uniq.join("|")
      @path_to_url ||= /\A(#{prefix})(\/?#{Regexp.escape(Jammit.public_root.sub(/#{prefix}/, ''))})?/
    end
1106822
def url(self):
        
        if self.server_url is not None and \
                self.recid is not None:
            return '/'.join(
                [self.server_url, CFG_SITE_RECORD, str(self.recid)])
        else:
            return None
832744
def getCanonicalRep(record_cluster):
    
    canonical_rep = {}

    keys = record_cluster[0].keys()

    for key in keys:
        key_values = []
        for record in record_cluster:
            # assume non-empty values always better than empty value
            # for canonical record
            if record[key]:
                key_values.append(record[key])
        if key_values:
            canonical_rep[key] = getCentroid(key_values, comparator)
        else:
            canonical_rep[key] = ''

    return canonical_rep
993352
function setAsRootDocument(doc) {
  rootDoc = doc;
  var window = rootDoc.defaultView;
  window.setTimeout = function(code, delay, arguments) {};
  window.setInterval = function(code, delay, arguments) {};
  anychartify(rootDoc);

  return rootDoc
}
1091710
def _api_path(self, item):
        """"""
        if self.base_url is None:
            raise NotImplementedError("base_url not set")
        path = "/".join([x.blob["id"] for x in item.path])
        return "/".join([self.base_url, path])
522454
def get_alias(path):
    
    # pylint:disable=too-many-return-statements

    record = model.PathAlias.get(path=path)

    if not record:
        return None, None

    template = record.template if record.template != 'index' else None

    if record.entry and record.entry.visible:
        if record.template:
            # a template was requested, so we go to the category page
            category = (record.category.category
                        if record.category else record.entry.category)
            return url_for('category',
                           start=record.entry.id,
                           template=template,
                           category=category), True

        from . import entry  # pylint:disable=cyclic-import
        outbound = entry.Entry(record.entry).get('Redirect-To')
        if outbound:
            # The entry has a Redirect-To (soft redirect) header
            return outbound, False

        return url_for('entry',
                       entry_id=record.entry.id,
                       category=record.entry.category,
                       slug_text=record.entry.slug_text), True

    if record.category:
        return url_for('category',
                       category=record.category.category,
                       template=template), True

    if record.url:
        # This is an outbound URL that might be changed by the user, so
        # we don't do a 301 Permanently moved
        return record.url, False

    return None, None
793733
def path_for_doc(self, doc_id):
        
        full_path = self.path_for_doc_fn(self.repo, doc_id)
        # _LOG.debug('>>>>>>>>>> GitActionBase.path_for_doc_fn: {}'.format(self.path_for_doc_fn))
        # _LOG.debug('>>>>>>>>>> GitActionBase.path_for_doc returning: [{}]'.format(full_path))
        return full_path
452624
def url(path, params = nil)
      if path.respond_to? :query
        if (query = path.query)
          path = path.dup
          path.query = nil
        end
      else
        anchor_index = path.index('#')
        path = path.slice(0, anchor_index) unless anchor_index.nil?
        path, query = path.split('?', 2)
      end
      self.path = path
      self.params.merge_query query, options.params_encoder
      self.params.update(params) if params
    end
249931
public static String getCanonicalURL(String url, String baseURL) {

		try {
			/* Build the absolute URL, from the url and the baseURL */
			String resolvedURL = URLResolver.resolveUrl(baseURL == null ? "" : baseURL, url);
			log.debug("Resolved URL: " + resolvedURL);
			URI canonicalURI;
			try {
				canonicalURI = new URI(resolvedURL);
			} catch (Exception e) {
				canonicalURI = new URI(URIUtil.encodeQuery(resolvedURL));
			}

			/* Some checking. */
			if (canonicalURI.getScheme() == null) {
				log.warn("Protocol could not be reliably evaluated from uri: " + canonicalURI + " and base url: " + baseURL);
				return null;
			}

			if (canonicalURI.getRawAuthority() == null) {
				log.debug("Ignoring URI with no authority (host[\":\"port]): " + canonicalURI + " (on base " + baseURL + ")");
				return null;
			}

			if (canonicalURI.getHost() == null) {
				log.warn("Host could not be reliably evaluated from: " + canonicalURI + " (on base " + baseURL + ")");
				return null;
			}

			/*
			 * Normalize: no empty segments (i.e., "//"), no segments equal to ".", and no segments equal to
			 * ".." that are preceded by a segment not equal to "..".
			 */
			String path = canonicalURI.normalize().getRawPath();

			/* Convert '//' -> '/' */
			int idx = path.indexOf("//");
			while (idx >= 0) {
				path = path.replace("//", "/");
				idx = path.indexOf("//");
			}

			/* Drop starting '/../' */
			while (path.startsWith("/../")) {
				path = path.substring(3);
			}

			/* Trim */
			path = path.trim();

			/* Process parameters and sort them. */
			final SortedSet<QueryParameter> params = createSortedParameters(canonicalURI.getRawQuery());
			final String queryString;
			String canonicalParams = canonicalize(params);
			queryString = (canonicalParams.isEmpty() ? "" : "?" + canonicalParams);

			/* Add starting slash if needed */
			if (path.length() == 0) {
				path = "/" + path;
			}

			/* Drop default port: example.com:80 -> example.com */
			int port = canonicalURI.getPort();
			if (isDefaultPort(canonicalURI.getScheme(), port)) {
				port = -1;
			}

			/* Lowercasing protocol and host */
			String protocol = canonicalURI.getScheme().toLowerCase();
			String host = canonicalURI.getHost().toLowerCase();
			String pathAndQueryString = normalizePath(path) + queryString;

			URL result = new URL(protocol, host, port, pathAndQueryString);
			return result.toExternalForm();

		} catch (Exception ex) {
			log.warn("Error while Processing URL [" + url + "] in the spidering process (on base " + baseURL + "): "
					+ ex.getMessage());
			return null;
		}
	}
1333000
def canonical_uri_path(self):
        
        result = getattr(self, "_canonical_uri_path", None)
        if result is None:
            result = self._canonical_uri_path = get_canonical_uri_path(
                self.uri_path)
        return result
450377
def extract_canonical(bs4):
    

    link_rel = bs4.select('link[rel="canonical"]')

    if link_rel.__len__() > 0:

        if link_rel[0].has_attr('href'):

            return link_rel[0]['href']

    return None
56546
def archive_url(self, entity_id, channel=None):
        '''
        '''
        url = '{}/{}/archive'.format(self.url, _get_path(entity_id))
        return _add_channel(url, channel)
1284401
public static String canonicalizeUrl(String url, String refer) {
        URL base;
        try {
            try {
                base = new URL(refer);
            } catch (MalformedURLException e) {
                // the base is unsuitable, but the attribute may be abs on its own, so try that
                URL abs = new URL(refer);
                return abs.toExternalForm();
            }
            // workaround: java resolves '//path/file + ?foo' to '//path/?foo', not '//path/file?foo' as desired
            if (url.startsWith("?"))
                url = base.getPath() + url;
            URL abs = new URL(base, url);
            return abs.toExternalForm();
        } catch (MalformedURLException e) {
            return "";
        }
    }
1272244
def canonical_key(self, key):
        """"""
        if key.startswith('/'):
            return urlparse.urljoin(self.base_uri, key)
        else:
            return self.curies.expand(key)