fix: non-ascii character in URL can not open issue. resolve #304
This commit is contained in:
parent
33d68e8b6d
commit
67aa1d670b
|
@ -69,10 +69,10 @@ extension SearchHistorySection {
|
|||
let trendHeaderRegister = UICollectionView.SupplementaryRegistration<SearchHistorySectionHeaderCollectionReusableView>(elementKind: UICollectionView.elementKindSectionHeader) { [weak dataSource] supplementaryView, elementKind, indexPath in
|
||||
supplementaryView.delegate = configuration.searchHistorySectionHeaderCollectionReusableViewDelegate
|
||||
|
||||
guard let dataSource = dataSource else { return }
|
||||
let sections = dataSource.snapshot().sectionIdentifiers
|
||||
guard indexPath.section < sections.count else { return }
|
||||
let section = sections[indexPath.section]
|
||||
guard let _ = dataSource else { return }
|
||||
// let sections = dataSource.snapshot().sectionIdentifiers
|
||||
// guard indexPath.section < sections.count else { return }
|
||||
// let section = sections[indexPath.section]
|
||||
}
|
||||
|
||||
dataSource.supplementaryViewProvider = { (collectionView: UICollectionView, elementKind: String, indexPath: IndexPath) in
|
||||
|
|
|
@ -38,11 +38,15 @@ extension DataSourceFacade {
|
|||
meta: Meta
|
||||
) async {
|
||||
switch meta {
|
||||
case .url(_, _, let url, _),
|
||||
.mention(_, let url, _) where url.lowercased().hasPrefix("http"):
|
||||
// note:
|
||||
// some server mark the normal url as "u-url" class. highlighted content is a URL
|
||||
guard let url = URL(string: url) else { return }
|
||||
case .url(_, _, let url, _),
|
||||
.mention(_, let url, _) where url.lowercased().hasPrefix("http"):
|
||||
// fix non-ascii character URL link can not open issue
|
||||
guard let url = URL(string: url) ?? URL(string: url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? url) else {
|
||||
assertionFailure()
|
||||
return
|
||||
}
|
||||
if let domain = provider.context.authenticationService.activeMastodonAuthenticationBox.value?.domain, url.host == domain,
|
||||
url.pathComponents.count >= 4,
|
||||
url.pathComponents[0] == "/",
|
||||
|
|
|
@ -757,7 +757,7 @@ extension StatusView: UITextViewDelegate {
|
|||
// MARK: - MetaTextViewDelegate
|
||||
extension StatusView: MetaTextViewDelegate {
|
||||
public func metaTextView(_ metaTextView: MetaTextView, didSelectMeta meta: Meta) {
|
||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)")
|
||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): meta: \(String(describing: meta))")
|
||||
switch metaTextView {
|
||||
case contentMetaText.textView:
|
||||
delegate?.statusView(self, metaText: contentMetaText, didSelectMeta: meta)
|
||||
|
|
Loading…
Reference in New Issue