Add "scheme" condition

Created on 7 July 2021, over 3 years ago
Updated 6 August 2024, 4 months 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.

Production build 0.71.5 2024