Prevent potential redirect loops
This commit is contained in:
parent
71b6352395
commit
182bb4b79b
|
@ -19,6 +19,14 @@ public class NavigationManager: NSObject, ObservableObject {
|
|||
@Published public var backStack = [URL]()
|
||||
@Published public var forwardStack = [URL]()
|
||||
|
||||
public var displayURL: String {
|
||||
var components = URLComponents(url: currentURL, resolvingAgainstBaseURL: false)!
|
||||
if components.port == 1965 {
|
||||
components.port = nil
|
||||
}
|
||||
return components.string!
|
||||
}
|
||||
|
||||
public init(url: URL) {
|
||||
self.currentURL = url
|
||||
}
|
||||
|
@ -30,9 +38,6 @@ public class NavigationManager: NSObject, ObservableObject {
|
|||
delegate?.loadNonGeminiURL(url)
|
||||
return
|
||||
}
|
||||
if components.port == 1965 {
|
||||
components.port = nil
|
||||
}
|
||||
} else {
|
||||
components.scheme = "gemini"
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ struct NavigationBar: View {
|
|||
|
||||
init(navigator: NavigationManager) {
|
||||
self.navigator = navigator
|
||||
self._urlFieldContents = State(initialValue: navigator.currentURL.absoluteString)
|
||||
self._urlFieldContents = State(initialValue: navigator.displayURL)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
|
@ -33,8 +33,8 @@ struct NavigationBar: View {
|
|||
.foregroundColor(Color(white: colorScheme == .dark ? 0.25 : 0.75))
|
||||
}
|
||||
.background(Color(UIColor.systemBackground).edgesIgnoringSafeArea(.top))
|
||||
.onReceive(navigator.$currentURL) { (newURL) in
|
||||
urlFieldContents = newURL.absoluteString
|
||||
.onReceive(navigator.$currentURL) { (_) in
|
||||
urlFieldContents = navigator.displayURL
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue