mirror of
https://github.com/yattee/yattee.git
synced 2026-04-09 17:16:57 +00:00
Fix HTTP basic auth credentials being stripped from instance URLs
Preserve user:pass credentials in instance URLs so Invidious instances behind nginx reverse proxies with HTTP basic auth work correctly (#926). Add displayURL property to mask credentials in the UI.
This commit is contained in:
@@ -119,6 +119,17 @@ struct Instance: Identifiable, Codable, Hashable, Sendable {
|
||||
name ?? url.host ?? url.absoluteString
|
||||
}
|
||||
|
||||
/// Returns the URL string with embedded credentials stripped for safe display in the UI.
|
||||
var displayURL: String {
|
||||
guard var components = URLComponents(url: url, resolvingAgainstBaseURL: false),
|
||||
components.user != nil else {
|
||||
return url.absoluteString
|
||||
}
|
||||
components.user = nil
|
||||
components.password = nil
|
||||
return components.url?.absoluteString ?? url.absoluteString
|
||||
}
|
||||
|
||||
var contentSource: ContentSource {
|
||||
type.contentSource(for: url)
|
||||
}
|
||||
@@ -268,10 +279,6 @@ extension Instance {
|
||||
components.path = String(components.path.dropLast())
|
||||
}
|
||||
|
||||
// Strip embedded credentials (security best practice)
|
||||
components.user = nil
|
||||
components.password = nil
|
||||
|
||||
return components.url
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ private struct EditRemoteServerContent: View {
|
||||
Form {
|
||||
Section {
|
||||
LabeledContent(String(localized: "sources.field.type"), value: instance.type.displayName)
|
||||
LabeledContent(String(localized: "sources.field.url"), value: instance.url.absoluteString)
|
||||
LabeledContent(String(localized: "sources.field.url"), value: instance.displayURL)
|
||||
}
|
||||
|
||||
Section {
|
||||
|
||||
Reference in New Issue
Block a user