Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/App/Core/Github.swift
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,8 @@ extension Github {
{
// Replace the image url and keep a copy of the old one in a `data` attribute
let s3Key = try S3Store.Key.readme(owner: owner, repository: repository, imageUrl: src)
try imageElement.attr("src", s3Key.objectUrl)
try imageElement.attr("data-original-src", src)
_ = try imageElement.attr("src", s3Key.objectUrl)
_ = try imageElement.attr("data-original-src", src)
imagesToCache.append(.init(originalUrl: src, s3Key: s3Key))
}
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/App/Views/DocumentationPageProcessor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -395,14 +395,14 @@ struct DocumentationPageProcessor {
if !value.lowercased().hasPrefix("/\(owner)/\(repository)/".lowercased()) {
// no /{owner}/{repo}/ prefix -> it's a dynamic base url resource, i.e. a "/" resource
// / -> /a/b/~ (current)
try e.attr(attribute, "/\(owner)/\(repository)/\(String.current)\(value)".lowercased())
_ = try e.attr(attribute, "/\(owner)/\(repository)/\(String.current)\(value)".lowercased())
} else if let reference {
let fullyQualifiedPrefix = "/\(owner)/\(repository)/\(reference)".lowercased()
if value.lowercased().hasPrefix(fullyQualifiedPrefix) {
// matches expected fully qualified resource path
// /a/b/1.2.3 -> /a/b/~ (current)
let trimmed = value.dropFirst(fullyQualifiedPrefix.count)
try e.attr(attribute, "/\(owner)/\(repository)/\(String.current)\(trimmed)".lowercased())
_ = try e.attr(attribute, "/\(owner)/\(repository)/\(String.current)\(trimmed)".lowercased())
} else {
// did not match expected resource prefix - leave it alone
// (shouldn't be possible)
Expand All @@ -417,7 +417,7 @@ struct DocumentationPageProcessor {
if !value.lowercased().hasPrefix("/\(owner)/\(repository)/".lowercased()) {
// no /{owner}/{repo}/ prefix -> it's a dynamic base url resource, i.e. a "/" resource
// / -> /a/b/~ (current)
try e.attr(attribute, "/\(owner)/\(repository)/\(reference)\(value)".lowercased())
_ = try e.attr(attribute, "/\(owner)/\(repository)/\(reference)\(value)".lowercased())
} else {
// already prefixed resource, leave it alone
return
Expand Down
10 changes: 5 additions & 5 deletions Sources/App/Views/PackageController/PackageReadme+Model.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ extension Element {
for imageElement in imageElements {
if let imageUrl = URL(withPotentiallyUnencodedPath: try imageElement.attr("src")),
let absoluteUrl = imageUrl.rewriteRelative(to: repoTriple, fileType: .raw) {
try imageElement.attr("src", absoluteUrl)
_ = try imageElement.attr("src", absoluteUrl)
}
}
} catch {
Expand All @@ -99,7 +99,7 @@ extension Element {
for linkElement in linkElements {
if let linkUrl = URL(withPotentiallyUnencodedPath: try linkElement.attr("href")),
let absoluteUrl = linkUrl.rewriteRelative(to: repoTriple, fileType: .blob) {
try linkElement.attr("href", absoluteUrl)
_ = try linkElement.attr("href", absoluteUrl)
}
}
} catch {
Expand All @@ -116,7 +116,7 @@ extension Element {
if linkDestination.hasPrefix("#") {
// GitHub adds `user-content` to all anchor destinations but does not change
// the anchors that link to the destinations or match the case that it uses. :rollseyes:
try linkElement.attr("href", "#user-content-\(linkDestination.dropFirst().lowercased())")
_ = try linkElement.attr("href", "#user-content-\(linkDestination.dropFirst().lowercased())")
}
}
} catch {
Expand All @@ -131,7 +131,7 @@ extension Element {
for imageElement in imageElements {
let originalUrl = try imageElement.attr("data-canonical-src")
if originalUrl.hasPrefix("http") {
try imageElement.attr("src", originalUrl)
_ = try imageElement.attr("src", originalUrl)
}
}
} catch {
Expand All @@ -145,7 +145,7 @@ extension Element {
let linkElements = try select("a")
for linkElement in linkElements {
// Disable Turbo on *all* link elements.
try linkElement.attr("data-turbo", "false")
_ = try linkElement.attr("data-turbo", "false")
}
} catch {
// Errors are being intentionally eaten here. The worst that can happen if the
Expand Down
Loading