Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AnnounceFetcher.php

function AnnounceFetcher::validateUrl

Check whether a link is controlled by D.O.

Parameters

string $url: URL to check.

Return value

bool Return True if the URL is controlled by the D.O.

1 call to AnnounceFetcher::validateUrl()
AnnounceFetcher::fetch in core/modules/announcements_feed/src/AnnounceFetcher.php
Fetches the feed either from a local cache or fresh remotely.

File

core/modules/announcements_feed/src/AnnounceFetcher.php, line 95

Class

AnnounceFetcher
Service to fetch announcements from the external feed.

Namespace

Drupal\announcements_feed

Code

public static function validateUrl(string $url) : bool {
    if (empty($url)) {
        return FALSE;
    }
    $host = parse_url($url, PHP_URL_HOST);
    // First character can only be a letter or a digit.
    // @see https://www.rfc-editor.org/rfc/rfc1123#page-13
    return $host && preg_match('/^([a-zA-Z0-9][a-zA-Z0-9\\-_]*\\.)?drupal\\.org$/', $host);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal