// File: /workspace/github_cpp_makefile_star2_O2/mbourand[P]webserv/srcs/Utils/URL.cpp
// Function: URL::URL(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
URL::URL(const std::string& url)
	: _is_directory(false)
{
	if (url.size() == 0)
		throw std::invalid_argument("Empty url");

	if (url == "*")
	{
		_path = "*";
		return;
	}
	else if (url[0] == '/')
		parse_partial(url);
	else
		parse_full(url);

	if (_port.empty())
		_port = "80";
	if (_path.empty())
		_path = "/";

	if (_path.find_first_not_of('/') != std::string::npos && _path[_path.size() - 1] == '/')
	{
		while (_path[_path.size() - 1] == '/')
			_path = _path.substr(0, _path.size() - 1);
		_is_directory = true;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
leaq 0x2c9b6(%rip), %rax     # 0x42c28
movq %rax, (%rdi)
leaq 0x18(%rdi), %rax
movq %rax, 0x8(%rdi)
andq $0x0, 0x10(%rdi)
xorl %eax, %eax
movb %al, 0x18(%rdi)
leaq 0x38(%rdi), %rcx
movq %rcx, 0x28(%rdi)
andq $0x0, 0x30(%rdi)
movb %al, 0x38(%rdi)
leaq 0x58(%rdi), %rcx
movq %rcx, 0x48(%rdi)
andq $0x0, 0x50(%rdi)
movb %al, 0x58(%rdi)
leaq 0x78(%rdi), %rcx
movq %rcx, 0x68(%rdi)
andq $0x0, 0x70(%rdi)
movb %al, 0x78(%rdi)
leaq 0x98(%rdi), %rcx
movq %rcx, 0x88(%rdi)
andq $0x0, 0x90(%rdi)
movb %al, 0x98(%rdi)
leaq 0xb8(%rdi), %rcx
movq %rcx, 0xa8(%rdi)
andq $0x0, 0xb0(%rdi)
leaq 0x68(%rdi), %r14
leaq 0x88(%rdi), %r15
movb %al, 0xb8(%rdi)
leaq 0xd8(%rdi), %rcx
movq %rcx, 0xc8(%rdi)
andq $0x0, 0xd0(%rdi)
movb %al, 0xd8(%rdi)
movb %al, 0xe8(%rdi)
cmpq %rax, 0x8(%rsi)
je 0x1641d
movq %rsi, %r12
leaq 0x16497(%rip), %rsi     # 0x2c7c7
movq %r12, %rdi
callq 0x91b7
testb %al, %al
je 0x16350
leaq 0x16484(%rip), %rsi     # 0x2c7c7
movq %r15, %rdi
callq 0x7930
jmp 0x1640e
movq (%r12), %rax
cmpb $0x2f, (%rax)
jne 0x16366
movq %rbx, %rdi
movq %r12, %rsi
callq 0x164c6
jmp 0x16371
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1663c
cmpq $0x0, 0x70(%rbx)
jne 0x16387
leaq 0x16a9d(%rip), %rsi     # 0x2ce1c
movq %r14, %rdi
callq 0x7930
cmpq $0x0, 0x90(%rbx)
jne 0x163a0
leaq 0x166b0(%rip), %rsi     # 0x2ca48
movq %r15, %rdi
callq 0x7930
pushq $0x2f
popq %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0x74c0
cmpq $-0x1, %rax
je 0x1640e
movq 0x88(%rbx), %rax
movq 0x90(%rbx), %rcx
cmpb $0x2f, -0x1(%rax,%rcx)
jne 0x1640e
leaq 0x18(%rsp), %r12
cmpb $0x2f, -0x1(%rax,%rcx)
jne 0x16407
decq %rcx
movq %r12, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x7540
movq %r15, %rdi
movq %r12, %rsi
callq 0x75f0
movq %r12, %rdi
callq 0x79b8
movq 0x88(%rbx), %rax
movq 0x90(%rbx), %rcx
jmp 0x163cd
movb $0x1, 0xe8(%rbx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x7290
movq %rax, %r13
leaq 0x169e3(%rip), %rsi     # 0x2ce12
movq %rax, %rdi
callq 0x7910
movq 0x2cb8a(%rip), %rsi     # 0x42fc8
movq 0x2cb6b(%rip), %rdx     # 0x42fb0
movq %r13, %rdi
callq 0x7830
movq %rax, 0x8(%rsp)
movq %r13, %rdi
callq 0x73d0
jmp 0x16463
jmp 0x1645e
movq %rax, 0x8(%rsp)
leaq 0x8(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x28(%rbx), %rbp
leaq 0x48(%rbx), %r12
leaq 0xa8(%rbx), %r13
addq $0xc8, %rbx
movq %rbx, %rdi
callq 0x79b8
movq %r13, %rdi
callq 0x79b8
movq %r15, %rdi
callq 0x79b8
movq %r14, %rdi
callq 0x79b8
movq %r12, %rdi
callq 0x79b8
movq %rbp, %rdi
callq 0x79b8
movq 0x10(%rsp), %rdi
callq 0x79b8
movq 0x8(%rsp), %rdi
callq 0x7860