Refactor generate_url_link by moving base_url logic into its own method. Add support for current protocol and current port.