Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit 96dcb92

Browse files
committed
Throw on invalid URL in style URL inspectable
If the user enters an invalid URL into the “Style URL” inspectable, throw an error instead of silently setting the style to the default. This check is not required in -setStyleURL:, which takes a real NSURL.
1 parent b1773fa commit 96dcb92

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

platform/ios/MGLMapView.mm

+7-1
Original file line numberDiff line numberDiff line change
@@ -3299,7 +3299,13 @@ - (nullable NSString *)styleURL__
32993299

33003300
- (void)setStyleURL__:(nullable NSString *)URLString
33013301
{
3302-
self.styleURL = URLString ? [NSURL URLWithString:URLString] : nil;
3302+
NSURL *url = URLString.length ? [NSURL URLWithString:URLString] : nil;
3303+
if (URLString.length && !url)
3304+
{
3305+
[NSException raise:@"Invalid style URL" format:
3306+
@"%@” is not a valid style URL.", URLString];
3307+
}
3308+
self.styleURL = url;
33033309
}
33043310

33053311
+ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingLatitude

0 commit comments

Comments
 (0)