mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-05 00:15:32 +00:00
chore: move to .localhost for local server URLs
Match website-local-proxy nginx server setup. Test-bot: skip
This commit is contained in:
parent
40ee518d54
commit
593aa1448b
5 changed files with 26 additions and 26 deletions
|
|
@ -66,11 +66,11 @@ const
|
||||||
URLPath_Community = '/go/'+SKeymanVersion+'/community';
|
URLPath_Community = '/go/'+SKeymanVersion+'/community';
|
||||||
|
|
||||||
// Keyboard download and installation
|
// Keyboard download and installation
|
||||||
URLPath_RegEx_MatchKeyboardsInstall = '^http(?:s)?://keyman(?:-staging)?\.com(?:\.local)?/keyboards/install/([^?/]+)(?:\?(.+))?$';
|
URLPath_RegEx_MatchKeyboardsInstall = '^http(?:s)?://keyman(?:-staging)?\.com(?:\.localhost)?/keyboards/install/([^?/]+)(?:\?(.+))?$';
|
||||||
// e.g. https://keyman.com/keyboards/install/foo
|
// e.g. https://keyman.com/keyboards/install/foo
|
||||||
UrlPath_RegEx_MatchKeyboardsRoot = '^http(?:s)?://keyman(?:-staging)?\.com(?:\.local)?/keyboards([/?].*)?$';
|
UrlPath_RegEx_MatchKeyboardsRoot = '^http(?:s)?://keyman(?:-staging)?\.com(?:\.localhost)?/keyboards([/?].*)?$';
|
||||||
// e.g. http://keyman.com.local/keyboards/foo
|
// e.g. http://keyman.com.localhost/keyboards/foo
|
||||||
UrlPath_RegEx_MatchKeyboardsGo = '^http(?:s)?://keyman(?:-staging)?\.com(?:\.local)?/go/windows/[^/]+/download-keyboards';
|
UrlPath_RegEx_MatchKeyboardsGo = '^http(?:s)?://keyman(?:-staging)?\.com(?:\.localhost)?/go/windows/[^/]+/download-keyboards';
|
||||||
// e.g. https://keyman-staging.com/go/windows/14.0/download-keyboards?version=14.0.146.0
|
// e.g. https://keyman-staging.com/go/windows/14.0/download-keyboards?version=14.0.146.0
|
||||||
|
|
||||||
// Cloning keyboards - Keyman Developer
|
// Cloning keyboards - Keyman Developer
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import Foundation
|
||||||
*/
|
*/
|
||||||
public enum KeymanHosts {
|
public enum KeymanHosts {
|
||||||
/**
|
/**
|
||||||
* Used to enable '.local' variants of the endpoints for use in local development testing.
|
* Used to enable '.localhost' variants of the endpoints for use in local development testing.
|
||||||
*/
|
*/
|
||||||
internal static let useLocal = false
|
internal static let useLocal = false
|
||||||
|
|
||||||
|
|
@ -24,7 +24,7 @@ public enum KeymanHosts {
|
||||||
// save for use in automated testing.
|
// save for use in automated testing.
|
||||||
internal static func getApiSiteURL(forTier: Version.Tier, useLocal: Bool) -> URL {
|
internal static func getApiSiteURL(forTier: Version.Tier, useLocal: Bool) -> URL {
|
||||||
if useLocal {
|
if useLocal {
|
||||||
return URL.init(string: "http://api.keyman.com.local")!
|
return URL.init(string: "http://api.keyman.com.localhost")!
|
||||||
} else {
|
} else {
|
||||||
switch forTier {
|
switch forTier {
|
||||||
case .alpha:
|
case .alpha:
|
||||||
|
|
@ -48,7 +48,7 @@ public enum KeymanHosts {
|
||||||
// save for use in automated testing.
|
// save for use in automated testing.
|
||||||
internal static func getHelpSiteURL(forTier: Version.Tier, useLocal: Bool) -> URL {
|
internal static func getHelpSiteURL(forTier: Version.Tier, useLocal: Bool) -> URL {
|
||||||
if useLocal {
|
if useLocal {
|
||||||
return URL.init(string: "http://help.keyman.com.local")!
|
return URL.init(string: "http://help.keyman.com.localhost")!
|
||||||
} else {
|
} else {
|
||||||
switch forTier {
|
switch forTier {
|
||||||
case .alpha:
|
case .alpha:
|
||||||
|
|
@ -72,7 +72,7 @@ public enum KeymanHosts {
|
||||||
// save for use in automated testing.
|
// save for use in automated testing.
|
||||||
internal static func getMainSiteURL(forTier: Version.Tier, useLocal: Bool) -> URL {
|
internal static func getMainSiteURL(forTier: Version.Tier, useLocal: Bool) -> URL {
|
||||||
if useLocal {
|
if useLocal {
|
||||||
return URL.init(string: "http://keyman.com.local")!
|
return URL.init(string: "http://keyman.com.localhost")!
|
||||||
} else {
|
} else {
|
||||||
switch forTier {
|
switch forTier {
|
||||||
case .alpha:
|
case .alpha:
|
||||||
|
|
|
||||||
|
|
@ -25,11 +25,11 @@ public class UniversalLinks {
|
||||||
public static var externalLinkLauncher: ((URL) -> Void)? = nil
|
public static var externalLinkLauncher: ((URL) -> Void)? = nil
|
||||||
|
|
||||||
// e.g. https://keyman.com/keyboards/install/foo
|
// e.g. https://keyman.com/keyboards/install/foo
|
||||||
private static let KEYBOARD_INSTALL_LINK_REGEX = try! NSRegularExpression(pattern: "^http(?:s)?://keyman(?:-staging)?\\.com(?:\\.local)?/keyboards/install/([^?/]+)(?:\\?(.+))?$")
|
private static let KEYBOARD_INSTALL_LINK_REGEX = try! NSRegularExpression(pattern: "^http(?:s)?://keyman(?:-staging)?\\.com(?:\\.localhost)?/keyboards/install/([^?/]+)(?:\\?(.+))?$")
|
||||||
// e.g. http://keyman.com.local/keyboards/foo
|
// e.g. http://keyman.com.localhost/keyboards/foo
|
||||||
private static let KEYBOARD_MATCH_ROOT_REGEX = try! NSRegularExpression(pattern: "^http(?:s)?://keyman(?:-staging)?\\.com(?:\\.local)?/keyboards([/?].*)?$");
|
private static let KEYBOARD_MATCH_ROOT_REGEX = try! NSRegularExpression(pattern: "^http(?:s)?://keyman(?:-staging)?\\.com(?:\\.localhost)?/keyboards([/?].*)?$");
|
||||||
// e.g. https://keyman-staging.com/go/windows/14.0/download-keyboards?version=14.0.146.0
|
// e.g. https://keyman-staging.com/go/windows/14.0/download-keyboards?version=14.0.146.0
|
||||||
private static let KEYBOARD_MATCH_GO_REGEX = try! NSRegularExpression(pattern: "^http(?:s)?://keyman(?:-staging)?\\.com(?:\\.local)?/go/windows/[^/]+/download-keyboards")
|
private static let KEYBOARD_MATCH_GO_REGEX = try! NSRegularExpression(pattern: "^http(?:s)?://keyman(?:-staging)?\\.com(?:\\.localhost)?/go/windows/[^/]+/download-keyboards")
|
||||||
|
|
||||||
public static func tryParseKeyboardInstallLink(_ link: URL) -> ParsedKeyboardInstallLink? {
|
public static func tryParseKeyboardInstallLink(_ link: URL) -> ParsedKeyboardInstallLink? {
|
||||||
let linkString = link.absoluteString
|
let linkString = link.absoluteString
|
||||||
|
|
|
||||||
|
|
@ -18,14 +18,14 @@ class KeymanHostTests: XCTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures no accidental permanent edits to the .local variant URLs occur.
|
* Ensures no accidental permanent edits to the .localhost variant URLs occur.
|
||||||
*/
|
*/
|
||||||
func testLocalSitesUnchanged() {
|
func testLocalSitesUnchanged() {
|
||||||
XCTAssertEqual(KeymanHosts.getApiSiteURL(forTier: .stable, useLocal: true),
|
XCTAssertEqual(KeymanHosts.getApiSiteURL(forTier: .stable, useLocal: true),
|
||||||
URL.init(string: "http://api.keyman.com.local"))
|
URL.init(string: "http://api.keyman.com.localhost"))
|
||||||
XCTAssertEqual(KeymanHosts.getHelpSiteURL(forTier: .stable, useLocal: true),
|
XCTAssertEqual(KeymanHosts.getHelpSiteURL(forTier: .stable, useLocal: true),
|
||||||
URL.init(string: "http://help.keyman.com.local"))
|
URL.init(string: "http://help.keyman.com.localhost"))
|
||||||
XCTAssertEqual(KeymanHosts.getMainSiteURL(forTier: .stable, useLocal: true),
|
XCTAssertEqual(KeymanHosts.getMainSiteURL(forTier: .stable, useLocal: true),
|
||||||
URL.init(string: "http://keyman.com.local"))
|
URL.init(string: "http://keyman.com.localhost"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,15 +22,15 @@
|
||||||
|
|
||||||
- (void)windowDidLoad {
|
- (void)windowDidLoad {
|
||||||
[super windowDidLoad];
|
[super windowDidLoad];
|
||||||
|
|
||||||
[self.webView setFrameLoadDelegate:(id<WebFrameLoadDelegate>)self];
|
[self.webView setFrameLoadDelegate:(id<WebFrameLoadDelegate>)self];
|
||||||
[self.webView setGroupName:@"KMDownloadKB"];
|
[self.webView setGroupName:@"KMDownloadKB"];
|
||||||
[self.webView setPolicyDelegate:(id<WebPolicyDelegate>)self];
|
[self.webView setPolicyDelegate:(id<WebPolicyDelegate>)self];
|
||||||
|
|
||||||
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
|
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
|
||||||
KeymanVersionInfo keymanVersionInfo = [[self AppDelegate] versionInfo];
|
KeymanVersionInfo keymanVersionInfo = [[self AppDelegate] versionInfo];
|
||||||
NSString *url = [NSString stringWithFormat:@"https://%@/go/macos/14.0/download-keyboards/?version=%@", keymanVersionInfo.keymanCom, version];
|
NSString *url = [NSString stringWithFormat:@"https://%@/go/macos/14.0/download-keyboards/?version=%@", keymanVersionInfo.keymanCom, version];
|
||||||
|
|
||||||
os_log_debug([KMLogs uiLog], "KMDownloadKBWindowController opening url = %@, version = '%@'", url, version);
|
os_log_debug([KMLogs uiLog], "KMDownloadKBWindowController opening url = %@, version = '%@'", url, version);
|
||||||
[self.webView.mainFrame loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
|
[self.webView.mainFrame loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
|
||||||
}
|
}
|
||||||
|
|
@ -45,21 +45,21 @@
|
||||||
os_log_debug([KMLogs uiLog], "decidePolicyForNavigationAction, navigating to %@", url);
|
os_log_debug([KMLogs uiLog], "decidePolicyForNavigationAction, navigating to %@", url);
|
||||||
|
|
||||||
// The pattern for matching links matches work in #3602
|
// The pattern for matching links matches work in #3602
|
||||||
NSString* urlPathMatchKeyboardsInstall = @"^http(?:s)?://keyman(?:-staging)?\\.com(?:\\.local)?/keyboards/install/([^?/]+)(?:\\?(.+))?$";
|
NSString* urlPathMatchKeyboardsInstall = @"^http(?:s)?://keyman(?:-staging)?\\.com(?:\\.localhost)?/keyboards/install/([^?/]+)(?:\\?(.+))?$";
|
||||||
// e.g. https://keyman.com/keyboards/install/foo
|
// e.g. https://keyman.com/keyboards/install/foo
|
||||||
NSString* urlPathMatchKeyboardsRoot = @"^http(?:s)?://keyman(?:-staging)?\\.com(?:\\.local)?/keyboards([/?].*)?$";
|
NSString* urlPathMatchKeyboardsRoot = @"^http(?:s)?://keyman(?:-staging)?\\.com(?:\\.localhost)?/keyboards([/?].*)?$";
|
||||||
// http://keyman.com.local/keyboards/foo
|
// http://keyman.com.localhost/keyboards/foo
|
||||||
NSString* urlPathMatchKeyboardsGo = @"^http(?:s)?://keyman(?:-staging)?\\.com(?:\\.local)?/go/macos/[^/]+/download-keyboards";
|
NSString* urlPathMatchKeyboardsGo = @"^http(?:s)?://keyman(?:-staging)?\\.com(?:\\.localhost)?/go/macos/[^/]+/download-keyboards";
|
||||||
// https://keyman-staging.com/go/macos/14.0/download-keyboards?version=14.0.146.0
|
// https://keyman-staging.com/go/macos/14.0/download-keyboards?version=14.0.146.0
|
||||||
NSRange range = NSMakeRange(0, url.length);
|
NSRange range = NSMakeRange(0, url.length);
|
||||||
|
|
||||||
NSError* error;
|
NSError* error;
|
||||||
NSRegularExpression* regexInstall = [NSRegularExpression regularExpressionWithPattern: urlPathMatchKeyboardsInstall options: 0 error: &error];
|
NSRegularExpression* regexInstall = [NSRegularExpression regularExpressionWithPattern: urlPathMatchKeyboardsInstall options: 0 error: &error];
|
||||||
NSRegularExpression* regexRoot = [NSRegularExpression regularExpressionWithPattern: urlPathMatchKeyboardsRoot options: 0 error: &error];
|
NSRegularExpression* regexRoot = [NSRegularExpression regularExpressionWithPattern: urlPathMatchKeyboardsRoot options: 0 error: &error];
|
||||||
NSRegularExpression* regexGo = [NSRegularExpression regularExpressionWithPattern: urlPathMatchKeyboardsGo options: 0 error: &error];
|
NSRegularExpression* regexGo = [NSRegularExpression regularExpressionWithPattern: urlPathMatchKeyboardsGo options: 0 error: &error];
|
||||||
|
|
||||||
NSArray* matchesInstall = [regexInstall matchesInString:url options:0 range:range];
|
NSArray* matchesInstall = [regexInstall matchesInString:url options:0 range:range];
|
||||||
|
|
||||||
if(matchesInstall.count > 0) {
|
if(matchesInstall.count > 0) {
|
||||||
os_log_debug([KMLogs uiLog], "Delegating download to app delegate.");
|
os_log_debug([KMLogs uiLog], "Delegating download to app delegate.");
|
||||||
[listener ignore];
|
[listener ignore];
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue