HTTPS地址在iOS和Android上的行为不同

发布于 2025-02-07 06:33:12 字数 992 浏览 2 评论 0原文

目前,使用Android应用程序为客户端为客户端修改日志记录逻辑,以便在iOS上工作。应用程序正在使用DIO进行HTTPS调用。地址作为字符串存储在单独的文件中(我们将其称为“设置”)。

显然无法提供原始链接,但它是这样的:

const String firstUrl = 'https://best-service-ever.com/access/';
const String secondUrl = 'https://another-good-service.com';

当前代码在记录脚本中看起来像这样的代码:

static Uri get firstUri => Uri.parse(settings.firstUrl);

  static Uri get loginUri =>
      firstUri.resolve('login').replace(queryParameters: <String, dynamic>{'service': settings.secondUrl});

android生成良好的loginuri - https://best-service-ever.com/access/ login?service = https:// another-good-service.com

,但出于iOS loginuri上的某些奇迹原因是https://best-service-ever-com/login? service=https:/service=https:/ /Another-Good-service.com

为什么以及仅在一个平台上进行解析时,终点将如何丢失?

**我也不能仅修改resolve('access/login')我需要在多个位置中的地址。

**我目前正在MacOS上运行Flutter Channel稳定2.10.5 11.6.5

Currently modding logging logic for client with working Android app to also work on iOS. App is using DIO to make and handle https calls. Addresses are stored in a separate file as strings (lets call it 'settings').

Obviously cannot provide original links but it goes something like this:

const String firstUrl = 'https://best-service-ever.com/access/';
const String secondUrl = 'https://another-good-service.com';

Currently code looks like this in logging script:

static Uri get firstUri => Uri.parse(settings.firstUrl);

  static Uri get loginUri =>
      firstUri.resolve('login').replace(queryParameters: <String, dynamic>{'service': settings.secondUrl});

Android generates good loginUri- https://best-service-ever.com/access/login?service=https://another-good-service.com

But for some miraculous reason on ios loginURI is https://best-service-ever.com/login?service=https://another-good-service.com.

Why and how the endpoint would be lost while parsing and only on one platform?

**Also I can't just modify resolve('access/login') i need the address in multiple places as is.

**Also I'm currently running Flutter channel stable 2.10.5 on macOS 11.6.5

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

递刀给你 2025-02-14 06:33:12

请这样尝试

const String firstUrl = 'https://best-service-ever.com/access/login';
const String secondUrl = 'https://another-good-service.com';
Uri  loginUri = Uri.parse(
    firstUrl).replace(queryParameters: <String, dynamic>{'service':secondUrl}); 
    print(loginUri); 

please try this way

const String firstUrl = 'https://best-service-ever.com/access/login';
const String secondUrl = 'https://another-good-service.com';
Uri  loginUri = Uri.parse(
    firstUrl).replace(queryParameters: <String, dynamic>{'service':secondUrl}); 
    print(loginUri); 
十年九夏 2025-02-14 06:33:12

看起来这可能是扑朔迷离的错误。然后,我可能会这样做,这样

String base = 'https://best-service-ever.com/';
String get firstUrl => '${base}access/';
String secondUrl = 'https://another-good-service.com';

static Uri get firstUri => Uri.parse(settings.firstUrl);
static Uri get base => Uri.parse(settings.base);
static Uri get loginUri =>
    base.resolve('access/login').replace(queryParameters: <String, dynamic>{'service': settings.secondUrl});

您仍然可以在代码的其余部分中使用原始firsturl

It looks like it might be a bug in flutter. I would then maybe work around it by doing it like this

String base = 'https://best-service-ever.com/';
String get firstUrl => '${base}access/';
String secondUrl = 'https://another-good-service.com';

static Uri get firstUri => Uri.parse(settings.firstUrl);
static Uri get base => Uri.parse(settings.base);
static Uri get loginUri =>
    base.resolve('access/login').replace(queryParameters: <String, dynamic>{'service': settings.secondUrl});

that way you can still use the original firstUrl in the rest of the code

别把无礼当个性 2025-02-14 06:33:12

而不是使用uri.parse尝试uri.https也许会有所帮助。
查看此官方链接以获取更多信息

Instead of using Uri.parse try Uri.https maybe it helps.
Check out this official link for more information

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文