[vlc-commits] [Git][videolan/vlc][master] bonjour: use NSURLComponents to construct URLs
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Fri Apr 3 04:50:43 UTC 2026
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
996b7524 by Felix Paul Kühne at 2026-04-03T06:15:43+02:00
bonjour: use NSURLComponents to construct URLs
This also solves missing brackets in IPv6 addresses and leads to an
overall cleaner implementation
- - - - -
1 changed file:
- modules/services_discovery/bonjour.m
Changes:
=====================================
modules/services_discovery/bonjour.m
=====================================
@@ -351,7 +351,11 @@ static NSString * ipAddressAsStringForData(NSData * data)
{
vlc_renderer_discovery_t *p_rd = (vlc_renderer_discovery_t *)_p_this;
- NSString *uri = [NSString stringWithFormat:@"%@://%@:%ld", protocol, netService.hostName, (long)netService.port];
+ NSURLComponents *components = [[NSURLComponents alloc] init];
+ components.scheme = protocol;
+ components.host = netService.hostName;
+ components.port = @(netService.port);
+ NSString *uri = components.URL.absoluteString;
NSDictionary *txtDict = [NSNetService dictionaryFromTXTRecordData:[netService TXTRecordData]];
NSString *displayName = netService.name;
int rendererFlags = 0;
@@ -414,7 +418,11 @@ static NSString * ipAddressAsStringForData(NSData * data)
if ([protocol isEqualToString:@"smb"]) {
host = ipAddressAsStringForData(netService.addresses.firstObject);
}
- NSString *uri = [NSString stringWithFormat:@"%@://%@:%ld", protocol, host, (long)netService.port];
+ NSURLComponents *components = [[NSURLComponents alloc] init];
+ components.scheme = protocol;
+ components.host = host;
+ components.port = @(netService.port);
+ NSString *uri = components.URL.absoluteString;
input_item_t *p_input_item = input_item_NewDirectory([uri UTF8String], [netService.name UTF8String], ITEM_NET );
if (p_input_item != NULL) {
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/996b7524ff6310dceb0e7d3c01551a69d71e5323
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/996b7524ff6310dceb0e7d3c01551a69d71e5323
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list