Skip to content

Commit 5c0d397

Browse files
committed
Strip punctuation from attribution
1 parent 70f3c91 commit 5c0d397

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

platform/darwin/src/MLNAttributionInfo.mm

+6-2
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,13 @@ @implementation MLNAttributionInfo
104104
[attributedString removeAttribute:NSStrokeWidthAttributeName range:range];
105105
}
106106

107-
// Omit whitespace-only strings.
107+
// Clean up strings by stripping punctuation and whitespace (often present for the web).
108+
NSMutableCharacterSet *charset = [NSMutableCharacterSet whitespaceAndNewlineCharacterSet];
109+
[charset formUnionWithCharacterSet:[NSCharacterSet punctuationCharacterSet]];
108110
NSAttributedString *title = [[attributedString attributedSubstringFromRange:range]
109-
mgl_attributedStringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
111+
mgl_attributedStringByTrimmingCharactersInSet:charset];
112+
113+
// Omit strings that are empty after cleaning.
110114
if (!title.length) {
111115
return;
112116
}

platform/darwin/test/MLNAttributionInfoTests.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ - (void)tearDown {
2020
- (void)testParsing {
2121
static NSString * const htmlStrings[] = {
2222
@"<a href=\"https://www.mapbox.com/about/maps/\" target=\"_blank\">&copy; Mapbox</a> "
23-
@"<a href=\"http://www.openstreetmap.org/about/\" target=\"_blank\">©️ OpenStreetMap</a> "
23+
@"<a href=\"http://www.openstreetmap.org/about/\" target=\"_blank\">©️ OpenStreetMap</a>, "
2424
@"CC&nbsp;BY-SA "
2525
@"<a class=\"mapbox-improve-map\" href=\"https://apps.mapbox.com/feedback/\" target=\"_blank\">Improve this map</a>",
2626
};

0 commit comments

Comments
 (0)