public function getRoute($name, array $args = [])
    {
        if (!isset($this->names[$name])) {
            return null;
        }

        $route = $this->callbacks[$this->names[$name]];

        if (strpos($route->pattern, '(') === false) {
            // If we don't have any route parameters, just return the pattern
            // straight off. No need for any regex stuff.
            return $route->pattern;
        }

        // Convert all placeholders to %o = optional and %r = required
        $from    = ['/(\([^\/]+[\)]+[\?])/', '/(\([^\/]+\))/'];
        $to      = ['%o', '%r'];
        $pattern = preg_replace($from, $to, $route->pattern);

        $frags = explode('/', trim($pattern, '/'));
        $url   = [];

        // Loop thru the pattern fragments and insert the arguments
        foreach ($frags as $frag) {
            if ($frag == '%r') {
                if (!$args) {
                    // A required parameter, but no more arguments.
                    throw new Exception('Missing route parameters');
                }
                $url[] = array_shift($args);
                continue;
            }

            if ($frag == "%o") {
                if (!$args) {
                    // No argument for the optional parameter,
                    // just continue the iteration.
                    continue;
                }
                $url[] = array_shift($args);
                continue;
            }

            $url[] = $frag;
        }

        return '/' . implode('/', $url);
    }