Skip to content

Commit f37d5fa

Browse files
authored
Move URL helpers to WordPressShared (#24236)
I run into one of the computed variables added to `URL` as part of #24165 when trying to move something related to `Media`. Moving to WordPressShared allows using the helpers in multiple modules and is a nice little standalone change that we can lock in already.
1 parent c85c6d2 commit f37d5fa

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

WordPress/Classes/Extensions/URL+Helpers.swift Modules/Sources/WordPressShared/URL+Helpers.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ import Foundation
22
import MobileCoreServices
33
import UniformTypeIdentifiers
44

5-
extension URL {
5+
public extension URL {
66

77
struct Helpers {
8-
static func temporaryFile(named name: String = UUID().uuidString) -> URL {
8+
public static func temporaryFile(named name: String = UUID().uuidString) -> URL {
99
if #available(iOS 16.0, *) {
1010
return URL.temporaryDirectory.appending(path: name)
1111
} else {
1212
return URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(name)
1313
}
1414
}
1515

16-
static func temporaryDirectory(named name: String) -> URL {
16+
public static func temporaryDirectory(named name: String) -> URL {
1717
if #available(iOS 16.0, *) {
1818
return URL.temporaryDirectory.appending(path: name, directoryHint: .isDirectory)
1919
} else {
@@ -106,7 +106,7 @@ extension URL {
106106
}
107107
}
108108

109-
extension NSURL {
109+
public extension NSURL {
110110
@objc var isVideo: Bool {
111111
return (self as URL).isVideo
112112
}
@@ -120,7 +120,7 @@ extension NSURL {
120120

121121
}
122122

123-
extension URL {
123+
public extension URL {
124124
/// Appends query items to the URL.
125125
/// - Parameter newQueryItems: The new query items to add to the URL. These will **not** overwrite any existing items but are appended to the existing list.
126126
/// - Returns: The URL with added query items.
@@ -134,7 +134,7 @@ extension URL {
134134

135135
/// Gravatar doesn't support "Cache-Control: none" header. So we add a random query parameter to
136136
/// bypass the backend cache and get the latest image.
137-
public func appendingGravatarCacheBusterParam() -> URL {
137+
func appendingGravatarCacheBusterParam() -> URL {
138138
var urlComponents = URLComponents(url: self, resolvingAgainstBaseURL: false)
139139
if urlComponents?.queryItems == nil {
140140
urlComponents?.queryItems = []

WordPress/Classes/Categories/Media+Extensions.m

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#import "MediaService.h"
33
#import "Blog.h"
44
@import WordPressDataObjC;
5+
@import WordPressShared;
56
#import "WordPress-Swift.h"
67

78
@implementation Media (Extensions)

WordPress/Classes/Services/MediaService.m

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#import "Media.h"
44
#import "WPAccount.h"
55
@import WordPressDataObjC;
6+
@import WordPressShared;
67
#import "Blog.h"
78
#import <MobileCoreServices/MobileCoreServices.h>
89
#import "WordPress-Swift.h"

WordPress/WordPress.xcodeproj/project.pbxproj

-2
Original file line numberDiff line numberDiff line change
@@ -3289,7 +3289,6 @@
32893289
membershipExceptions = (
32903290
"Extensions/String+Helpers.swift",
32913291
"Extensions/UIImage+Extensions.swift",
3292-
"Extensions/URL+Helpers.swift",
32933292
"Utility/App Configuration/AppConfiguration.swift",
32943293
"Utility/App Configuration/ExtensionConfiguration.swift",
32953294
Utility/BuildInformation/BuildConfiguration.swift,
@@ -3391,7 +3390,6 @@
33913390
membershipExceptions = (
33923391
"Extensions/String+Helpers.swift",
33933392
"Extensions/UIImage+Extensions.swift",
3394-
"Extensions/URL+Helpers.swift",
33953393
Utility/BuildInformation/BuildConfiguration.swift,
33963394
Utility/FormattableContent/Actions/DefaultFormattableContentAction.swift,
33973395
Utility/FormattableContent/Actions/FormattableContentAction.swift,

0 commit comments

Comments
 (0)