DmitryDulepov\Realurl\Decoder\UrlDecoder::checkMissingSlash PHP Метод

checkMissingSlash() защищенный Метод

Checks if the missing slash should be corrected.
protected checkMissingSlash ( ) : void
Результат void
    protected function checkMissingSlash()
    {
        $this->speakingUri = rtrim($this->speakingUri, '?');
        $regexp = '~^([^\\?]*[^/])(\\?.*)?$~';
        if (preg_match($regexp, $this->speakingUri)) {
            // Only process if a slash is missing:
            $options = GeneralUtility::trimExplode(',', $this->configuration->get('init/appendMissingSlash'), true);
            if (in_array('ifNotFile', $options)) {
                if (!preg_match('/\\/[^\\/\\?]+\\.[^\\/]+(\\?.*)?$/', '/' . $this->speakingUri)) {
                    $this->speakingUri = preg_replace($regexp, '\\1/\\2', $this->speakingUri);
                    $this->appendedSlash = true;
                }
            } else {
                $this->speakingUri = preg_replace($regexp, '\\1/\\2', $this->speakingUri);
                $this->appendedSlash = true;
            }
            if ($this->appendedSlash && count($options) > 0) {
                foreach ($options as $option) {
                    $matches = array();
                    if (preg_match('/^redirect(\\[(30[1237])\\])?$/', $option, $matches)) {
                        $code = count($matches) > 1 ? $matches[2] : 301;
                        $status = 'HTTP/1.1 ' . $code . ' TYPO3 RealURL redirect';
                        // Check path segment to be relative for the current site.
                        // parse_url() does not work with relative URLs, so we use it to test
                        if (!@parse_url($this->speakingUri, PHP_URL_HOST)) {
                            @ob_end_clean();
                            header($status);
                            header(self::REDIRECT_INFO_HEADER . ': redirect for missing slash');
                            header('Location: ' . GeneralUtility::locationHeaderUrl($this->speakingUri));
                            exit;
                        }
                    }
                }
            }
        }
    }