You are here

function _fontawesome_unparse_url in Font Awesome Icons 7.3

Same name and namespace in other branches
  1. 8.2 fontawesome.module \_fontawesome_unparse_url()

Unparses a CDN URL for use with individual Font Awesome file inclusions.

Parameters

array $parsed: Array containing URL parsed data.

Return value

string The unparsed URL for the CDN.

1 call to _fontawesome_unparse_url()
_fontawesome_get_base_path in ./fontawesome.module
Gets the base path for a CDN.

File

./fontawesome.module, line 280
Drupal integration with Font Awesome 5.

Code

function _fontawesome_unparse_url(array $parsed) {
  $get = function ($key) use ($parsed) {
    return isset($parsed[$key]) ? $parsed[$key] : NULL;
  };
  $pass = $get('pass');
  $user = $get('user');
  $userinfo = $pass !== NULL ? "{$user}:{$pass}" : $user;
  $port = $get('port');
  $scheme = $get('scheme');
  $query = $get('query');
  $fragment = $get('fragment');
  $authority = ($userinfo !== NULL ? "{$userinfo}@" : '') . $get('host') . ($port ? ":{$port}" : '');
  return (strlen($scheme) ? "{$scheme}:" : '') . (strlen($authority) ? "//{$authority}" : '') . $get('path') . (strlen($query) ? "?{$query}" : '') . (strlen($fragment) ? "#{$fragment}" : '');
}