src/Service.php
public function checkWhitelist(string $url): bool
	{
		$pluginSettings = EmbeddedAssets::$plugin->getSettings();
		$whitelist = array_merge($pluginSettings->whitelist, $pluginSettings->extraWhitelist);

		foreach ($whitelist as $whitelistUrl)
		{
			if ($whitelistUrl)
			{
				$pattern = explode('*', $whitelistUrl);
				$pattern = array_map('preg_quote', $pattern);
				$pattern = implode('[a-z][a-z0-9]*', $pattern);
				$pattern = "%^(https?:)?//([a-z0-9\-]+\\.)?$pattern([:/].*)?$%";

				if (preg_match($pattern, $url))
				{
					return true;
				}
			}
		}

		return false;
	}
public function checkWhitelist(string $url): bool
	{
		$pluginSettings = EmbeddedAssets::$plugin->getSettings();
		$whitelist = array_merge($pluginSettings->whitelist, $pluginSettings->extraWhitelist);

		foreach ($whitelist as $whitelistUrl)
		{
			if ($whitelistUrl)
			{
				$pattern = explode('*', $whitelistUrl);
				$pattern = array_map('preg_quote', $pattern);
				$pattern = implode('[a-z][a-z0-9]*', $pattern);
				$pattern = "%^(https?:)?//([a-z0-9\-]+\\.)?$pattern([:/].*)?$%";

				if (preg_match($pattern, $url))
				{
					return true;
				}
			}
		}

		return false;
	}
public function checkWhitelist ( string $ url ) : bool { $ pluginSettings = EmbeddedAssets :: $ plugin -> getSettings ( ) ; $ whitelist = array_merge ( $ pluginSettings -> whitelist , $ pluginSettings -> extraWhitelist ) ; foreach ( $ whitelist as $ whitelistUrl ) { if ( $ whitelistUrl ) { $ pattern = explode ( '*' , $ whitelistUrl ) ; $ pattern = array_map ( 'preg_quote' , $ pattern ) ; $ pattern = implode ( '[a-z][a-z0-9]*' , $ pattern ) ; $ pattern = "%^(https?:)?//([a-z0-9\-]+\\.)?$pattern([:/].*)?$%" ; if ( preg_match ( $ pattern , $ url ) ) { return true ; } } } return false ; }
Checks a URL against the whitelist set on the plugin settings model.

@param string $url
@return bool Whether the URL is in the whitelist.
Checks a URL against the whitelist set on the plugin settings model .