//
//  URLExtension.swift
//  Zockerhoehle
//
//  Created by Julian-Steffen Müller on 15.05.21.
//  Copyright © 2021 Julian-Steffen Müller. All rights reserved.
//

import Foundation

extension URL {
    /*
     This function created
     */
    func relative_path_after(pathComponent seperator_components : [String]) -> String? {
        var seperators = seperator_components
        
        var url = URL(string: "")
        for path_component in pathComponents {
            if seperators.count == 0 {
                if url == .none {
                    url = URL(string: path_component)
                }else {
                    url = url?.appendingPathComponent(path_component)
                }
            }else{
                if seperators.first! == path_component {
                    seperators.removeFirst()
                }
            }
        }
        
        return url?.absoluteString ?? .none
    }
}
