﻿using System;
using System.Net;
using System.Threading.Tasks;

namespace JPassword8.Core
{
    public static class URILauncher
    {
        public static string Correct(string url)
        {
            if (string.IsNullOrWhiteSpace(url))
                return string.Empty;

            string http = "";
            string body = "";

            if (url.Contains("https://"))
                body = url.Replace("https://", "");
            else if (url.Contains("http://"))
                body = url.Replace("http://", "");
            else
                body = url;

            http = url.Contains("https://") ? "https://" : "http://";

            return http + body;
        }

        public async static void Run(string url)
        {
            if (string.IsNullOrWhiteSpace(url))
                return;

            await Windows.System.Launcher.LaunchUriAsync(new Uri(url));
        }
    }
}
