Add "scheme" condition

Created on 7 July 2021, almost 3 years ago
Updated 18 April 2023, about 1 year ago

Disable cdn for files provided in modules, themes etc

In this case files from themes, modules etc processed by cdn and as a result these files can't be accessible.

 protected function canServe(string $uri) : bool {
    $scheme = StreamWrapperManager::getScheme($uri);

    // Allow additional stream wrappers to be served via CDN.
    $allowed_stream_wrappers = $this->settings->getStreamWrappers();
    // If the URI is absolute β€” HTTP(S) or otherwise β€” return early, except if
    // it's an absolute URI using an allowed stream wrapper.
    if ($scheme && !in_array($scheme, $allowed_stream_wrappers, TRUE)) {
      return FALSE;
    }
    // If the URI is scheme-relative, return early.
    elseif (mb_substr($uri, 0, 2) === '//') {
      return FALSE;
    }
    return TRUE;
  }

this code will return true for such files because $scheme in that case is FALSE

Proposal is to add an settings to disable cdn files

If this checkbox is enabled files what have $scheme === FALSE will be ignored for cdn.

✨ Feature request
Status

Needs work

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine mmv93

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    πŸ“Œ 10.1.x compatibility: tests are failing against Drupal 10.1.x due to upstream changes Fixed made existing tests pass on Drupal 10.1.

    But πŸ“Œ Make css/js optimized assets path configurable Fixed means that CSS/JS aggregates are now no longer served from the public:// stream wrapper, but from a new assets:// stream wrapper.

    That means that the existing nocssjs preset could be implemented differently. Choices:

    • Simplest: also always allow the assets:// stream wrapper and keep the preset unchanged (which generates conditions: { not: { extensions: [css, js] }})
    • Alternative: make nocssjs map to not allowing assets://. We'd still need the same conditions for non-aggregated CSS/JS assets though.

    If we go the alternative route, then this issue presumably becomes a hard requirement.

Production build 0.69.0 2024