// File: /workspace/github_cpp_makefile_star2_O1/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 $0x58, %rsp
movq %rdi, %rbx
leaq 0x32a42(%rip), %rax     # 0x4dc10
movq %rax, (%rdi)
leaq 0x18(%rdi), %rax
movq %rax, 0x28(%rsp)
movq %rax, 0x8(%rdi)
xorl %eax, %eax
movq %rax, 0x10(%rdi)
movb %al, 0x18(%rdi)
leaq 0x38(%rdi), %rcx
movq %rcx, 0x20(%rsp)
movq %rcx, 0x28(%rdi)
movq %rax, 0x30(%rdi)
movb %al, 0x38(%rdi)
leaq 0x58(%rdi), %rcx
movq %rcx, 0x18(%rsp)
movq %rcx, 0x48(%rdi)
movq %rax, 0x50(%rdi)
movb %al, 0x58(%rdi)
leaq 0x68(%rdi), %rcx
movq %rcx, 0x30(%rsp)
leaq 0x78(%rdi), %rcx
movq %rcx, 0x10(%rsp)
movq %rcx, 0x68(%rdi)
movq %rax, 0x70(%rdi)
movb %al, 0x78(%rdi)
leaq 0x88(%rdi), %r15
leaq 0x98(%rdi), %rcx
movq %rcx, 0x8(%rsp)
movq %rcx, 0x88(%rdi)
movq %rax, 0x90(%rdi)
movb %al, 0x98(%rdi)
leaq 0xb8(%rdi), %r14
movq %r14, 0xa8(%rdi)
movq %rax, 0xb0(%rdi)
movb %al, 0xb8(%rdi)
leaq 0xd8(%rdi), %rbp
movq %rbp, 0xc8(%rdi)
movq %rax, 0xd0(%rdi)
movb %al, 0xd8(%rdi)
movb %al, 0xe8(%rdi)
cmpq %rax, 0x8(%rsi)
je 0x1b3e6
movq %rsi, %r12
leaq 0x1f570(%rip), %rsi     # 0x3a813
movq %r12, %rdi
callq 0x7180
testl %eax, %eax
je 0x1b2c5
movq (%r12), %rax
cmpb $0x2f, (%rax)
jne 0x1b2e8
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1b4ec
jmp 0x1b2f3
movq 0x90(%rbx), %rdx
leaq 0x1f540(%rip), %rcx     # 0x3a813
movl $0x1, %r8d
movq %r15, %rdi
xorl %esi, %esi
callq 0x76f0
jmp 0x1b3d7
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1b698
movq 0x70(%rbx), %rdx
testq %rdx, %rdx
jne 0x1b315
leaq 0x1fb65(%rip), %rcx     # 0x3ae68
movl $0x2, %r8d
movq 0x30(%rsp), %rdi
xorl %esi, %esi
callq 0x76f0
movq 0x90(%rbx), %rdx
testq %rdx, %rdx
jne 0x1b338
leaq 0x1f76c(%rip), %rcx     # 0x3aa94
movl $0x1, %r8d
movq %r15, %rdi
xorl %esi, %esi
callq 0x76f0
movq %r15, %rdi
movl $0x2f, %esi
xorl %edx, %edx
callq 0x7440
cmpq $-0x1, %rax
je 0x1b3d7
movq 0x88(%rbx), %rax
movq 0x90(%rbx), %rcx
cmpb $0x2f, -0x1(%rax,%rcx)
jne 0x1b3d7
movq 0x88(%rbx), %rax
movq 0x90(%rbx), %rcx
cmpb $0x2f, -0x1(%rax,%rcx)
jne 0x1b3d0
decq %rcx
leaq 0x48(%rsp), %r13
leaq 0x38(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x74d0
movq %r15, %rdi
movq %r12, %rsi
callq 0x7590
movq 0x38(%rsp), %rdi
cmpq %r13, %rdi
je 0x1b3b7
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x74b0
movq 0x88(%rbx), %rax
movq 0x90(%rbx), %rdx
leaq -0x1(%rdx), %rcx
cmpb $0x2f, -0x1(%rax,%rdx)
je 0x1b388
movb $0x1, 0xe8(%rbx)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x7260
movq %rax, %r13
leaq 0x1fa64(%rip), %rsi     # 0x3ae5e
movq %rax, %rdi
callq 0x78c0
movq 0x32bbf(%rip), %rsi     # 0x4dfc8
movq 0x32ba0(%rip), %rdx     # 0x4dfb0
movq %r13, %rdi
callq 0x77d0
movq %rax, %r12
movq %r13, %rdi
callq 0x7390
jmp 0x1b42a
jmp 0x1b427
movq %rax, %r12
movq 0xc8(%rbx), %rdi
cmpq %rbp, %rdi
je 0x1b442
movq (%rbp), %rsi
incq %rsi
callq 0x74b0
movq 0xa8(%rbx), %rdi
cmpq %r14, %rdi
je 0x1b459
movq (%r14), %rsi
incq %rsi
callq 0x74b0
movq (%r15), %rdi
cmpq 0x8(%rsp), %rdi
je 0x1b473
movq 0x8(%rsp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x74b0
movq 0x30(%rsp), %rax
movq (%rax), %rdi
cmpq 0x10(%rsp), %rdi
je 0x1b492
movq 0x10(%rsp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x74b0
movq 0x48(%rbx), %rdi
cmpq 0x18(%rsp), %rdi
je 0x1b4ad
movq 0x18(%rsp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x74b0
movq 0x28(%rbx), %rdi
cmpq 0x20(%rsp), %rdi
je 0x1b4c8
movq 0x20(%rsp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x74b0
movq 0x8(%rbx), %rdi
cmpq 0x28(%rsp), %rdi
je 0x1b4e3
movq 0x28(%rsp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x74b0
movq %r12, %rdi
callq 0x7810
nop