src/Filter/FilterUrlBuilder.php
public function addFromCurrentRequest(FilterUrl $filterUrl, $options = null): void
    {
        if (null === $options) {
            $options = [
                'postAsSlug'  => [],
                'postAsGet'   => [],
                'preserveGet' => true
            ];
        }

        $request = $this->requestStack->getMasterRequest();

        if (isset($options['preserveGet'])) {
            foreach ($request->query->all() as $name => $value) {
                $filterUrl->setGet($name, $value);
            }
        }

        if (null === $fragments = $this->determineFragments($request)) {
            return;
        }

        $filterUrl->setPageValue('alias', $fragments[0]);
        // Add the fragments to the slug array
        for ($i = 1, $c = \count($fragments); $i < $c; $i += 2) {
            // Skip key value pairs if the key is empty (see contao/core/#4702)
            if ('' === $fragments[$i]) {
                continue;
            }

            // Decode slashes in slugs - They got encoded in generate() above.
            $filterUrl->setSlug(
                $this->decodeForAllowEncodedSlashes($fragments[$i]),
                $this->decodeForAllowEncodedSlashes($fragments[($i + 1)])
            );
        }

        $this->extractPostData($filterUrl, $options, $request);
    }
public function addFromCurrentRequest(FilterUrl $filterUrl, $options = null): void
    {
        if (null === $options) {
            $options = [
                'postAsSlug'  => [],
                'postAsGet'   => [],
                'preserveGet' => true
            ];
        }

        $request = $this->requestStack->getMasterRequest();

        if (isset($options['preserveGet'])) {
            foreach ($request->query->all() as $name => $value) {
                $filterUrl->setGet($name, $value);
            }
        }

        if (null === $fragments = $this->determineFragments($request)) {
            return;
        }

        $filterUrl->setPageValue('alias', $fragments[0]);
        // Add the fragments to the slug array
        for ($i = 1, $c = \count($fragments); $i < $c; $i += 2) {
            // Skip key value pairs if the key is empty (see contao/core/#4702)
            if ('' === $fragments[$i]) {
                continue;
            }

            // Decode slashes in slugs - They got encoded in generate() above.
            $filterUrl->setSlug(
                $this->decodeForAllowEncodedSlashes($fragments[$i]),
                $this->decodeForAllowEncodedSlashes($fragments[($i + 1)])
            );
        }

        $this->extractPostData($filterUrl, $options, $request);
    }
Split the current request into fragments, strip the URL suffix, recreate the $_GET array and return the page ID

This is mostly based on \Contao\Frontend::getPageIdFromUrl() but stripped off of some checks.

Options may be:
bool postAsSlug  Fields of POST data that shall be added to the slug entries.
default: []
bool postAsGet   Fields of POST data that shall be added to the GET entries.
default: []
bool preserveGet Flag if the GET parameters shall be added to the filter URL.
default: true

@param FilterUrl $filterUrl The filter URL to update.
@param array     $options   The options for updating.

@return void