-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathString+File.swift
More file actions
41 lines (31 loc) · 866 Bytes
/
Copy pathString+File.swift
File metadata and controls
41 lines (31 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//
// String+File.swift
// StringFormat
//
// Created by coderyi on 2020/12/12.
//
import Foundation
extension String {
static var FilePrefix = "file://"
subscript (i: Int) -> Character {
return self[index(startIndex, offsetBy: i)]
}
public var isMarkdown: Bool {
return hasSuffix(".md") || hasSuffix(".markdown")
}
public var isBaseFile: Bool {
return self == "file:///" || self == "file://"
}
public var isWebLink: Bool {
return contains("http")
}
public var removingPercentEncoding: String {
return self.removingPercentEncoding ?? self
}
public var isWhiteSpace: Bool {
return self.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
}
func trim() -> String {
return trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
}
}