src/Builder.php
protected function pageFilename(Page $page, $lang=null)
    {
        // We basically want the page $page->id(), but localized for multilang
        $url = $page->url($lang);
        // Strip the temporary URL prefix
        $url = trim(str_replace(static::URLPREFIX, '', $url), '/');
        // Page URL fragment should not contain a protocol or domain name at this point;
        // did we fail to override the base URL with static::URLPREFIX?
        if (Str::startsWith($url, 'http') || Str::contains($url, '://')) {
            throw new Exception("Cannot use '$url' as basis for page's file name.");
        }
        // Special case: home page
        if (!$url) {
            $file = $this->outputdir . '/index.html';
        }
        // Don’t add any extension if we already have one in the URL
        // (using a short whitelist for likely use cases).
        elseif (preg_match('/\.(js|json|css|txt|svg|xml|atom|rss)$/i', $url)) {
            $file = $this->outputdir . '/' . $url;
        }
        else {
            $file = $this->outputdir . '/' . $url . $this->extension;
        }
        $validPath = $this->normalizePath($file);
        if ($this->filterPath($validPath) == false) {
            throw new Exception('Output path for page goes outside of static directory: ' . $file);
        }
        return $validPath;
    }
protected function pageFilename(Page $page, $lang=null)
    {
        // We basically want the page $page->id(), but localized for multilang
        $url = $page->url($lang);
        // Strip the temporary URL prefix
        $url = trim(str_replace(static::URLPREFIX, '', $url), '/');
        // Page URL fragment should not contain a protocol or domain name at this point;
        // did we fail to override the base URL with static::URLPREFIX?
        if (Str::startsWith($url, 'http') || Str::contains($url, '://')) {
            throw new Exception("Cannot use '$url' as basis for page's file name.");
        }
        // Special case: home page
        if (!$url) {
            $file = $this->outputdir . '/index.html';
        }
        // Don’t add any extension if we already have one in the URL
        // (using a short whitelist for likely use cases).
        elseif (preg_match('/\.(js|json|css|txt|svg|xml|atom|rss)$/i', $url)) {
            $file = $this->outputdir . '/' . $url;
        }
        else {
            $file = $this->outputdir . '/' . $url . $this->extension;
        }
        $validPath = $this->normalizePath($file);
        if ($this->filterPath($validPath) == false) {
            throw new Exception('Output path for page goes outside of static directory: ' . $file);
        }
        return $validPath;
    }
protected function pageFilename ( Page $ page , $ lang = null ) { // We basically want the page $page->id(), but localized for multilang $ url = $ page -> url ( $ lang ) ; // Strip the temporary URL prefix $ url = trim ( str_replace ( static :: URLPREFIX , '' , $ url ) , '/' ) ; // Page URL fragment should not contain a protocol or domain name at this point; // did we fail to override the base URL with static::URLPREFIX? if ( Str :: startsWith ( $ url , 'http' ) || Str :: contains ( $ url , '://' ) ) { throw new Exception ( "Cannot use '$url' as basis for page's file name." ) ; } // Special case: home page if ( ! $ url ) { $ file = $ this -> outputdir . '/index.html' ; } // Don’t add any extension if we already have one in the URL // (using a short whitelist for likely use cases). elseif ( preg_match ( '/\.(js|json|css|txt|svg|xml|atom|rss)$/i' , $ url ) ) { $ file = $ this -> outputdir . '/' . $ url ; } else { $ file = $ this -> outputdir . '/' . $ url . $ this -> extension ; } $ validPath = $ this -> normalizePath ( $ file ) ; if ( $ this -> filterPath ( $ validPath ) == false ) { throw new Exception ( 'Output path for page goes outside of static directory: ' . $ file ) ; } return $ validPath ; }
Generate the file path that a page should be written to
@param Page $page
@param string|null $lang
@return string
@throws Exception
Generate the file path that a page should be written to