Path: blob/master/src/applications/meta/engineextension/PhabricatorDatasourceURIEngineExtension.php
12256 views
<?php12final class PhabricatorDatasourceURIEngineExtension3extends PhabricatorDatasourceEngineExtension {45public function newQuickSearchDatasources() {6return array();7}89public function newJumpURI($query) {10// If you search for a URI on the local install, just redirect to that11// URI as though you had pasted it into the URI bar.12if (PhabricatorEnv::isSelfURI($query)) {13// Strip off the absolute part of the URI. If we don't, the URI redirect14// validator will get upset that we're performing an unmarked external15// redirect.1617// The correct host and protocol may also differ from the host and18// protocol used in the search: for example, if you search for "http://"19// we want to redirect to "https://" if an install is HTTPS, and20// the "isSelfURI()" check includes alternate domains in addition to the21// canonical domain.2223$uri = id(new PhutilURI($query))24->setDomain(null)25->setProtocol(null)26->setPort(null);2728$uri = phutil_string_cast($uri);2930// See T13412. If the URI was in the form "http://dev.example.com" with31// no trailing slash, there may be no path. Redirecting to the empty32// string is considered an error by safety checks during redirection,33// so treat this like the user entered the URI with a trailing slash.34if (!strlen($uri)) {35$uri = '/';36}3738return $uri;39}4041return null;42}43}444546