public function __construct()

in app/classes/ReleaseInsights/Request.php [14:55]


    public function __construct(string $path)
    {
        $request = parse_url($path);

        // Paths that start with multiple slashes don't have a correct (or any) 'path' field via parse_url()
        if (str_starts_with($path, '//')) {
            $this->invalid_slashes = true;
        }

        // Real files are not processes as paths to route
        if ($request !== false) {
            // We sometimes use a fake query on a static asset to force the browser to refresh the cache,
            // we take the query out when checking if the file path exists
            if (file_exists($_SERVER['DOCUMENT_ROOT'] . explode('?', $path)[0])) {
                $this->invalid_slashes = false;
                $this->path = explode('?', $path)[0];
            } else {
                // We have a real path to route and clean up before usage
                $this->request = $path;

                if (isset($request['path'])) {
                    $this->path = $this->cleanPath($request['path']);
                }

                if (isset($request['query'])) {
                    $this->query = $request['query'];
                }

                if (isset($request['path'])) {
                    if (str_ends_with($request['path'], '//')) {
                        // Multiple slashes at the end of the path
                        $this->invalid_slashes = true;
                    } elseif (! str_ends_with($request['path'], '/')) {
                        // Missing slash at the end of the path
                        $this->invalid_slashes = true;
                    } else {
                        $this->invalid_slashes = false;
                    }
                }
            }
        }
    }