//
//  MBIMURLUtilities.m
//  kordophoned
//
//  Created by James Magahern on 1/17/23.
//  Copyright © 2023 James Magahern. All rights reserved.
//

#import "MBIMURLUtilities.h"

@implementation NSURL (MBIMURLUtilities)

- (nullable NSString *)valueForQueryItemWithName:(NSString *)queryItemName
{
    NSURLComponents *urlComponents = [NSURLComponents componentsWithURL:self resolvingAgainstBaseURL:NO];
    
    NSString *value = nil;
    for (NSURLQueryItem *queryItem in [urlComponents queryItems]) {
        if ([[queryItem name] isEqualToString:queryItemName]) {
            value = [queryItem value];
            break;
        }
    }
    
    return value;
}

@end
