ObjFW  Diff

Differences From Artifact [7c53691cc2]:

To Artifact [3b200a0eea]:


74
75
76
77
78
79
80





81
82
83
84
85
86
87
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92







+
+
+
+
+








	objc_autoreleasePoolPop(pool);

	return [ret autorelease];
}

@implementation OFURL
+ (instancetype)URL
{
	return [[[self alloc] init] autorelease];
}

+ (instancetype)URLWithString: (OFString*)string
{
	return [[[self alloc] initWithString: string] autorelease];
}

+ (instancetype)URLWithString: (OFString*)string
		relativeToURL: (OFURL*)URL
509
510
511
512
513
514
515

516


517
518
519
520
521
522
523
524

525

526
527
528
529
530
531
532
533

534

535
536
537
538
539
540
541
514
515
516
517
518
519
520
521

522
523
524
525
526
527
528
529
530
531
532

533
534
535
536
537
538
539
540
541
542

543
544
545
546
547
548
549
550







+
-
+
+








+
-
+








+
-
+







- (OFString*)string
{
	OFMutableString *ret = [OFMutableString stringWithFormat: @"%@://",
								  scheme];
	BOOL needPort = YES;

	if ([scheme isEqual: @"file"]) {
		if (path != nil)
		[ret appendString: path];
			[ret appendString: path];

		return ret;
	}

	if (user != nil && password != nil)
		[ret appendFormat: @"%@:%@@", user, password];
	else if (user != nil)
		[ret appendFormat: @"%@@", user];

	if (host != nil)
	[ret appendString: host];
		[ret appendString: host];

	if (([scheme isEqual: @"http"] && port == 80) ||
	    ([scheme isEqual: @"https"] && port == 443))
		needPort = NO;

	if (needPort)
		[ret appendFormat: @":%d", port];

	if (path != nil)
	[ret appendString: path];
		[ret appendString: path];

	if (parameters != nil)
		[ret appendFormat: @";%@", parameters];

	if (query != nil)
		[ret appendFormat: @"?%@", query];