Sometimes you have URLs without http:// OR https:// into WordPress post content.
So you can use the following function for that. You can use this function for the_content filter for WP. And also you can use this anywhere in PHP code other than WP.
<?php
/**
* Fix the URLs from the content.
*
* This function will add protocol to URLs which has no protocol added.