Skip to content

./include/functions.php - formatURL :: Add ability to set secure URL #529

@zyspec

Description

@zyspec

Enhancement
Add a 2nd parameter to formatURL() function to allow requesting a secure url. For backward compatibility function should return http as the default.

/**
 * formatURL()
 *
 * @param mixed $url
 * @param bool $secure true to return https, else return http
 * @return mixed|string
 */
function formatURL($url, $secure=false)
{
    $url = trim($url);
    if ($url != '') {
        if ((!preg_match('/^http[s]*:\/\//i', $url)) && (!preg_match('/^ftp*:\/\//i', $url)) && (!preg_match('/^ed2k*:\/\//i', $url))) {
            $url = (bool)$secure ? 'https://' . $url : 'http://' . $url;
        }
    }

    return $url;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions