public function generateSegments(string $root = null): void
    {
        $path = rawurldecode($this->sourceData['path'] ?? '');
        if ($path && $path != '/') {
            // drop root if exists
            if ($root && $root != '/') {
                $root = '/'. trim($root, '/'). '/';
                // prevent wrong generate action
                if (strpos($path, $root) === false) {
                    throw new HttpException("Uri path '{$path}' has no root such '{$root}'");
                }

                $path = substr($path, strlen($root));

                // update segments root
                $this->segmentsRoot = $root;
            }

            $segments = array_map('trim', preg_split('~/+~', $path, -1, PREG_SPLIT_NO_EMPTY));
            if ($segments != null) {
                // push index next
                foreach ($segments as $i => $segment) {
                    $this->segments[$i + 1] = $segment;
                }
            }
        }
    }