Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions NSString+minifyJSONString.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// Created by Bödecs Tibor on 7/19/13.
// Copyright (c) 2013 Bödecs Tibor. All rights reserved.
//
// Patched by Kyle Simpson, 2021
//

#import "NSString+minifyJSONString.h"

Expand All @@ -20,14 +22,15 @@ - (NSString *)minifyJSONString
NSString *tmp2;
NSMutableArray *new_str = [@[] mutableCopy];
int from = 0;
int prevFrom = 0;
NSString *lc;
NSString *rc;
int lastIndex = 0;

NSRegularExpression *tokenizer = [NSRegularExpression regularExpressionWithPattern:@"\"|(\\/\\*)|(\\*\\/)|(\\/\\/)|\n|\r"
options:NSRegularExpressionCaseInsensitive
error:nil];
NSRegularExpression *magic = [NSRegularExpression regularExpressionWithPattern:@"(\\\\)*$"
NSRegularExpression *magic = [NSRegularExpression regularExpressionWithPattern:@"(\\\\)+$"
options:NSRegularExpressionCaseInsensitive
error:nil];

Expand All @@ -53,12 +56,13 @@ - (NSString *)minifyJSONString
}
[new_str addObject:tmp2];
}
prevFrom = from;
from = lastIndex;

if ( [tmp hasPrefix:@"\""] && !in_multiline_comment && !in_singleline_comment) {
NSArray *_matches = [magic matchesInString:lc
options:0
range:NSMakeRange(0, lc.length)];
range:NSMakeRange(prevFrom, lc.length)];

if (_matches.count > 0 ) {
NSTextCheckingResult *_match = _matches[0];
Expand Down