<commit_before>//
//  URL+Utils.swift
//  APExtensions
//
//  Created by <NAME> on 11/1/17.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import Foundation


public extension URL {
    /// File name without extension. Nil if it's directory.
    @available(iOS 9.0, *)
    public var fileName: String? {
        guard !hasDirectoryPath else { return nil }
        
        return String(lastPathComponent.split(separator: ".")[0])
    }
    
    /// Check if it's URL to local file
    @available(iOS 9.0, *)
    public var isLocalFile: Bool {
        return !hasDirectoryPath && isFileURL
    }
    
    /// Appends path component and prevents double slashes if URL has trailing slash and path component has leading slash.
    public func smartAppendingPathComponent(_ pathComponent: String, isDirectory: Bool = false) -> URL {
        guard !pathComponent.isEmpty else { return self }
        
        var pathComponent = pathComponent
        if pathComponent[0] == "/" {
            pathComponent = String(pathComponent.dropFirst())
        }
        
        return appendingPathComponent(pathComponent, isDirectory: isDirectory)
    }
}<commit_msg>- URL .isLocalDirectory<commit_after>//
//  URL+Utils.swift
//  APExtensions
//
//  Created by <NAME> on 11/1/17.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import Foundation


public extension URL {
    /// File name without extension. Nil if it's directory.
    @available(iOS 9.0, *)
    public var fileName: String? {
        guard !hasDirectoryPath else { return nil }
        
        return String(lastPathComponent.split(separator: ".")[0])
    }
    
    /// Check if it's URL to local directory
    @available(iOS 9.0, *)
    public var isLocalDirectory: Bool {
        return isFileURL && hasDirectoryPath
    }
    
    /// Check if it's URL to local file
    @available(iOS 9.0, *)
    public var isLocalFile: Bool {
        return isFileURL && !hasDirectoryPath
    }
    
    /// Appends path component and prevents double slashes if URL has trailing slash and path component has leading slash.
    public func smartAppendingPathComponent(_ pathComponent: String, isDirectory: Bool = false) -> URL {
        guard !pathComponent.isEmpty else { return self }
        
        var pathComponent = pathComponent
        if pathComponent[0] == "/" {
            pathComponent = String(pathComponent.dropFirst())
        }
        
        return appendingPathComponent(pathComponent, isDirectory: isDirectory)
    }
}
{'fraction_non_alphanumeric': 0.0988, 'fraction_numerical': 0.0128, 'mean_word_length': 2.4213406292749657, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5558592', 'n_tokens_mistral': 717, 'n_tokens_neox': 664, 'n_words': 220}