Skip to content

Commit 1790ae6

Browse files
move common identifier validation logic out of Prerelease.swift
It’s used for more than validating prerelease.
1 parent ecbede7 commit 1790ae6

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
This source file is part of the Swift.org open source project
3+
4+
Copyright (c) 2022 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See https://swift.org/LICENSE.txt for license information
8+
See https://swift.org/CONTRIBUTORS.txt for Swift project authors
9+
*/
10+
11+
extension Character {
12+
/// A Boolean value indicating whether this character is allowed in a semantic version's identifier.
13+
internal var isAllowedInSemanticVersionIdentifier: Bool {
14+
isASCII && (isLetter || isNumber || self == "-")
15+
}
16+
17+
/// A Boolean value indicating whether this character is allowed in a semantic version's numeric identifier.
18+
internal var isAllowedInSemanticVersionNumericIdentifier: Bool {
19+
isASCII && isNumber
20+
}
21+
}

Sources/SymbolKit/SymbolGraph/SemanticVersion/Prerelease.swift

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,3 @@ extension SymbolGraph.SemanticVersion.Prerelease.Identifier: CustomStringConvert
142142
}
143143
}
144144
}
145-
146-
// MARK: - Validating Identifiers
147-
148-
extension Character {
149-
/// A Boolean value indicating whether this character is allowed in a semantic version's identifier.
150-
internal var isAllowedInSemanticVersionIdentifier: Bool {
151-
isASCII && (isLetter || isNumber || self == "-")
152-
}
153-
154-
/// A Boolean value indicating whether this character is allowed in a semantic version's numeric identifier.
155-
internal var isAllowedInSemanticVersionNumericIdentifier: Bool {
156-
isASCII && isNumber
157-
}
158-
}

0 commit comments

Comments
 (0)