MOBILE-258: Allow path prefix for operaionsDomain#741
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for specifying operationsDomain with an optional path prefix (e.g. domain.com/api/v2) so operations endpoints are appended after that prefix, enabling deployments behind reverse proxies/anonymizers.
Changes:
- Extend validation to accept
host/path-prefixforoperationsDomain(while keepingdomainhost-only). - Update URL building to append route paths to any existing base-path prefix.
- Add unit tests covering routing, configuration validation, and config policy normalization/rejection rules for path prefixes.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Mindbox/Network/Helpers/URLRequestBuilder.swift | Appends route.path onto any base URL path prefix when building requests. |
| Mindbox/Network/Helpers/HostNormalizer.swift | Documents support for optional path prefixes in normalized host inputs. |
| Mindbox/Validators/URLValidator.swift | Adds isValidHostWithOptionalPath for validating operationsDomain with an optional path prefix. |
| Mindbox/MBConfiguration.swift | Allows operationsDomain values that include a path prefix; keeps domain validation host-only. |
| Mindbox/InAppMessages/Configuration/Services/OperationsDomainConfigPolicy.swift | Updates config policy validation to accept path-prefix forms and keep canonical storage behavior. |
| MindboxTests/Network/OperationsURLRoutingTests.swift | Adds routing tests ensuring path prefixes are preserved and concatenated correctly. |
| MindboxTests/Configuration/MBConfigurationTests.swift | Adds configuration tests for acceptance/rejection of path-prefix operationsDomain values. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Vailence
left a comment
There was a problem hiding this comment.
Пофиксить бы один комментарий, и можно мержить
| /// Path-prefix rule for `isValidHostWithOptionalPath`: zero or more non-empty | ||
| /// segments of unreserved URL characters. Query, fragment and empty segments | ||
| /// do not match. | ||
| private static let pathPrefixPattern = "^(?:/[A-Za-z0-9._~%-]+)*$" |
There was a problem hiding this comment.
pathPrefixPattern разрешает % как обычный символ, не проверяя, что это валидный percent-escape. В итоге domain.com/a%zz проходит валидацию в MBConfiguration.init без ошибки, а падает уже в рантайме: URLComponents(string:) возвращает nil → badURL на каждом запросе
https://tracker.yandex.ru/MOBILE-258