diff --git a/platform/darwin/src/MLNAttributionInfo.mm b/platform/darwin/src/MLNAttributionInfo.mm index 42b4dc935..0de8e407a 100644 --- a/platform/darwin/src/MLNAttributionInfo.mm +++ b/platform/darwin/src/MLNAttributionInfo.mm @@ -104,9 +104,13 @@ [attributedString removeAttribute:NSStrokeWidthAttributeName range:range]; } - // Omit whitespace-only strings. + // Clean up strings by stripping punctuation and whitespace (often present for the web). + NSMutableCharacterSet *charset = [NSMutableCharacterSet whitespaceAndNewlineCharacterSet]; + [charset formUnionWithCharacterSet:[NSCharacterSet punctuationCharacterSet]]; NSAttributedString *title = [[attributedString attributedSubstringFromRange:range] - mgl_attributedStringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + mgl_attributedStringByTrimmingCharactersInSet:charset]; + + // Omit strings that are empty after cleaning. if (!title.length) { return; } diff --git a/platform/darwin/test/MLNAttributionInfoTests.m b/platform/darwin/test/MLNAttributionInfoTests.m index 340dce49b..612716f25 100644 --- a/platform/darwin/test/MLNAttributionInfoTests.m +++ b/platform/darwin/test/MLNAttributionInfoTests.m @@ -20,7 +20,7 @@ - (void)testParsing { static NSString * const htmlStrings[] = { @"© Mapbox " - @"©️ OpenStreetMap " + @"©️ OpenStreetMap, " @"CC BY-SA " @"Improve this map", };