1+ require_relative "function_api_base_url_policy"
2+
13XCODE_WORKSPACE = "DevLog.xcworkspace"
24XCODE_PROJ = "Application/App/App.xcodeproj"
35WIDGET_XCODE_PROJ = "Widget/WidgetExtension/WidgetExtension.xcodeproj"
@@ -13,7 +15,8 @@ TESTFLIGHT_APP_ENVIRONMENT = "staging"
1315APPSTORE_APP_ENVIRONMENT = "prod"
1416TESTFLIGHT_DATABASE_ID = "(default)"
1517APPSTORE_DATABASE_ID = "(default)"
16- SHARED_FUNCTION_API_PATH = "/api/api"
18+ TESTFLIGHT_FUNCTION_API_PATH = "/api"
19+ APPSTORE_FUNCTION_API_PATH = "/api/api"
1720APP_CONFIG_XCCONFIG_PATH = File . expand_path (
1821 "../Application/App/Sources/Resource/Config.xcconfig" ,
1922 __dir__
@@ -114,19 +117,13 @@ rescue SystemCallError => error
114117 UI . user_error! ( "Could not read app configuration file at #{ expanded_path } : #{ error . message } " )
115118end
116119
117- def verify_function_api_base_url_policy ( function_api_base_url )
118- require "uri"
119-
120- uri = URI . parse ( function_api_base_url )
121- is_valid = uri . is_a? ( URI ::HTTPS ) &&
122- !uri . host . to_s . empty? &&
123- uri . path == SHARED_FUNCTION_API_PATH &&
124- uri . query . nil? &&
125- uri . fragment . nil?
120+ def verify_function_api_base_url_policy ( function_api_base_url , expected_path :)
121+ is_valid = FunctionAPIBaseURLPolicy . valid? (
122+ function_api_base_url ,
123+ expected_path : expected_path
124+ )
126125
127126 UI . user_error! ( "Invalid FUNCTION_API_BASE_URL for store build" ) if !is_valid
128- rescue URI ::InvalidURIError
129- UI . user_error! ( "Invalid FUNCTION_API_BASE_URL for store build" )
130127end
131128
132129default_platform ( :ios )
@@ -180,12 +177,14 @@ platform :ios do
180177 when TESTFLIGHT_CONFIGURATION
181178 {
182179 database_id : TESTFLIGHT_DATABASE_ID ,
183- function_api_base_url : function_api_base_url_from_xcconfig ( TESTFLIGHT_CONFIGURATION )
180+ function_api_base_url : function_api_base_url_from_xcconfig ( TESTFLIGHT_CONFIGURATION ) ,
181+ function_api_path : TESTFLIGHT_FUNCTION_API_PATH
184182 }
185183 when APPSTORE_CONFIGURATION
186184 {
187185 database_id : APPSTORE_DATABASE_ID ,
188- function_api_base_url : function_api_base_url_from_xcconfig ( APPSTORE_CONFIGURATION )
186+ function_api_base_url : function_api_base_url_from_xcconfig ( APPSTORE_CONFIGURATION ) ,
187+ function_api_path : APPSTORE_FUNCTION_API_PATH
189188 }
190189 else
191190 UI . user_error! ( "Unsupported store configuration: #{ configuration } " )
@@ -194,7 +193,10 @@ platform :ios do
194193 UI . user_error! ( "Missing Firestore database ID for #{ configuration } " ) if database_id . empty?
195194 UI . user_error! ( "Missing Function API base URL for #{ configuration } " ) if function_api_base_url . empty?
196195
197- verify_function_api_base_url_policy ( function_api_base_url )
196+ verify_function_api_base_url_policy (
197+ function_api_base_url ,
198+ expected_path : expected_configuration [ :function_api_path ]
199+ )
198200
199201 if database_id != expected_configuration [ :database_id ]
200202 UI . user_error! (
0 commit comments