Strip punctuation from attribution (#3287)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
- (void)testParsing {
|
||||
static NSString * const htmlStrings[] = {
|
||||
@"<a href=\"https://www.mapbox.com/about/maps/\" target=\"_blank\">© Mapbox</a> "
|
||||
@"<a href=\"http://www.openstreetmap.org/about/\" target=\"_blank\">©️ OpenStreetMap</a> "
|
||||
@"<a href=\"http://www.openstreetmap.org/about/\" target=\"_blank\">©️ OpenStreetMap</a>, "
|
||||
@"CC BY-SA "
|
||||
@"<a class=\"mapbox-improve-map\" href=\"https://apps.mapbox.com/feedback/\" target=\"_blank\">Improve this map</a>",
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user