ObjFW  Diff

Differences From Artifact [45850285e0]:

To Artifact [9f39c392cd]:


394
395
396
397
398
399
400





401
402
403
404
405





406
407
408
409
410
411
412
413
414
415





416
417
418
419
420





421
422
423
424
425






426
427
428
429
430
431
432
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458







+
+
+
+
+





+
+
+
+
+










+
+
+
+
+





+
+
+
+
+





+
+
+
+
+
+







	return hash;
}

- (OFString *)scheme
{
	return _scheme;
}

- (OFString *)URLEncodedScheme
{
	return [_scheme stringByURLEncoding];
}

- (OFString *)host
{
	return _host;
}

- (OFString *)URLEncodedHost
{
	return [_host stringByURLEncoding];
}

- (OFNumber *)port
{
	return _port;
}

- (OFString *)user
{
	return _user;
}

- (OFString *)URLEncodedUser
{
	return [_user stringByURLEncoding];
}

- (OFString *)password
{
	return _password;
}

- (OFString *)URLEncodedPassword
{
	return [_password stringByURLEncoding];
}

- (OFString *)path
{
	return _path;
}

- (OFString *)URLEncodedPath
{
	return [_path stringByURLEncodingWithAllowedCharacters:
	    "-._~!$&'()*+,;=:@/"];
}

- (OFArray *)pathComponents
{
	return [_path componentsSeparatedByString: @"/"];
}

- (OFString *)lastPathComponent
469
470
471
472
473
474
475






476
477
478
479
480






481
482
483
484
485
486
487
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525







+
+
+
+
+
+





+
+
+
+
+
+







	return [ret autorelease];
}

- (OFString *)query
{
	return _query;
}

- (OFString *)URLEncodedQuery
{
	return [_query stringByURLEncodingWithAllowedCharacters:
	    "-._~!$&'()*+,;=:@/?"];
}

- (OFString *)fragment
{
	return _fragment;
}

- (OFString *)URLEncodedFragment
{
	return [_fragment stringByURLEncodingWithAllowedCharacters:
	    "-._~!$&'()*+,;=:@/?"];
}

- (id)copy
{
	return [self retain];
}

- (id)mutableCopy
506
507
508
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
542

543
544
545
546
547
548
549
550
551
544
545
546
547
548
549
550

551
552
553
554


555
556
557

558
559
560

561
562
563
564
565
566
567
568

569


570
571
572

573


574
575

576


577
578
579
580
581
582
583







-
+



-
-
+
+

-
+


-
+







-
+
-
-



-
+
-
-


-
+
-
-







}

- (OFString *)string
{
	OFMutableString *ret = [OFMutableString string];
	void *pool = objc_autoreleasePoolPush();

	[ret appendFormat: @"%@://", [_scheme stringByURLEncoding]];
	[ret appendFormat: @"%@://", [self URLEncodedScheme]];

	if (_user != nil && _password != nil)
		[ret appendFormat: @"%@:%@@",
				   [_user stringByURLEncoding],
				   [_password stringByURLEncoding]];
				   [self URLEncodedUser],
				   [self URLEncodedPassword]];
	else if (_user != nil)
		[ret appendFormat: @"%@@", [_user stringByURLEncoding]];
		[ret appendFormat: @"%@@", [self URLEncodedUser]];

	if (_host != nil)
		[ret appendString: [_host stringByURLEncoding]];
		[ret appendString: [self URLEncodedHost]];
	if (_port != nil)
		[ret appendFormat: @":%@", _port];

	if (_path != nil) {
		if (![_path hasPrefix: @"/"])
			@throw [OFInvalidFormatException exception];

		[ret appendString: [_path
		[ret appendString: [self URLEncodedPath]];
		    stringByURLEncodingWithAllowedCharacters:
		    "-._~!$&'()*+,;=:@/"]];
	}

	if (_query != nil)
		[ret appendFormat: @"?%@",
		[ret appendFormat: @"?%@", [self URLEncodedQuery]];
		    [_query stringByURLEncodingWithAllowedCharacters:
		    "-._~!$&'()*+,;=:@/?"]];

	if (_fragment != nil)
		[ret appendFormat: @"#%@",
		[ret appendFormat: @"#%@", [self URLEncodedFragment]];
		    [_fragment stringByURLEncodingWithAllowedCharacters:
		    "-._~!$&'()*+,;=:@/?"]];

	objc_autoreleasePoolPop(pool);

	[ret makeImmutable];

	return ret;
}