mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
cppkore uses string/wstring as StringBase while we use std::string/std::wstring as string/wstring. Changed all types in cppkore to String/WString instead.
57 lines
1.0 KiB
C++
57 lines
1.0 KiB
C++
#include "stdafx.h"
|
|
#include "Uri.h"
|
|
|
|
namespace Net
|
|
{
|
|
Uri::Uri(const char* Url)
|
|
: Uri(String(Url))
|
|
{
|
|
}
|
|
|
|
Uri::Uri(const String& Url)
|
|
: InternetPort(InternetPortType::Default), Host(""), Path("")
|
|
{
|
|
this->ParseUri(Url);
|
|
}
|
|
|
|
String Uri::GetUrl()
|
|
{
|
|
auto Base = (InternetPort == InternetPortType::Http) ? "http://" : "https://";
|
|
|
|
return Base + Host + Path;
|
|
}
|
|
|
|
void Uri::ParseUri(const String& Url)
|
|
{
|
|
auto LowerCaseUrl = Url.ToLower();
|
|
uint32_t ParsePoint = 0;
|
|
|
|
if (LowerCaseUrl.StartsWith("https://"))
|
|
{
|
|
this->InternetPort = InternetPortType::Https;
|
|
ParsePoint = 8;
|
|
}
|
|
else if (LowerCaseUrl.StartsWith("http://"))
|
|
{
|
|
this->InternetPort = InternetPortType::Http;
|
|
ParsePoint = 7;
|
|
}
|
|
else if (LowerCaseUrl.StartsWith("//"))
|
|
{
|
|
ParsePoint = 2;
|
|
}
|
|
|
|
auto PathStart = Url.IndexOf("/", ParsePoint);
|
|
|
|
if (PathStart != String::InvalidPosition)
|
|
{
|
|
this->Host = Url.SubString(ParsePoint, PathStart - ParsePoint);
|
|
this->Path = Url.SubString(PathStart + 1);
|
|
}
|
|
else
|
|
{
|
|
this->Host = Url.SubString(ParsePoint);
|
|
}
|
|
}
|
|
}
|