feat: Updates form routes and database routes to use id's in the url path.
This commit is contained in:
@@ -50,11 +50,7 @@ extension EffectiveLength.Update {
|
||||
form: SiteRoute.View.ProjectRoute.EquivalentLengthRoute.StepThree,
|
||||
projectID: Project.ID
|
||||
) throws {
|
||||
guard let id = form.id else {
|
||||
throw ValidationError("Id not found.")
|
||||
}
|
||||
self.init(
|
||||
id: id,
|
||||
name: form.name,
|
||||
type: form.type,
|
||||
straightLengths: form.straightLengths,
|
||||
|
||||
20
Sources/ViewController/Extensions/String+appendingPath.swift
Normal file
20
Sources/ViewController/Extensions/String+appendingPath.swift
Normal file
@@ -0,0 +1,20 @@
|
||||
import Foundation
|
||||
|
||||
extension String {
|
||||
|
||||
func appendingPath(_ string: String) -> Self {
|
||||
guard string.starts(with: "/") else {
|
||||
return self.appending("/\(string)")
|
||||
}
|
||||
return self.appending(string)
|
||||
}
|
||||
|
||||
func appendingPath(_ id: UUID?) -> Self {
|
||||
guard let id else { return self }
|
||||
return appendingPath(id.uuidString)
|
||||
}
|
||||
|
||||
func appendingPath(_ id: UUID) -> Self {
|
||||
return appendingPath(id.uuidString)
|
||||
}
|
||||
}
|
||||
7
Sources/ViewController/Extensions/UUID+idString.swift
Normal file
7
Sources/ViewController/Extensions/UUID+idString.swift
Normal file
@@ -0,0 +1,7 @@
|
||||
import Foundation
|
||||
|
||||
extension UUID {
|
||||
var idString: String {
|
||||
uuidString.replacing("-", with: "")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user