-
Notifications
You must be signed in to change notification settings - Fork 6k
[web] Add path-based browser location handling #17829
Conversation
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
1 similar comment
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
@googlebot I fixed it. |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
1 similar comment
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
Can we name it something that isn't SCREAMING_CAPS? Perhaps |
Or better yet |
@jonahwilliams I am matching the previous behaviour already existing in flutter engine for this:
|
That should also be updated to something friendly like |
eb24e62
to
66db24b
Compare
66db24b
to
cc80b21
Compare
@jonahwilliams updated to |
This is great! Thanks for working on this pain point facing many of flutter web users. The implementation of the location strategy looks good to me. My concern is around other aspects of this change. Like asset loading and service worker. If I understand correctly, assets and service worker caching, both use relative paths. This could cause issues when the user reloads the page. I could be completely wrong, so I would like @jonahwilliams to comment about this. |
Okay, thanks for the links @mdebbar I think I understand the situation better. It sounds like the solution is that users must specify an asset base directory to the framework/build and then flutter (framework side and service worker) must make http requests with these absolute URLs rather than the current strategy of using relative URLs? |
@jonahwilliams yes that's what I had to do when testing both PRs |
@jonahwilliams yep, that sounds right. |
@mdebbar, you mean adding a |
Please make sure that arguments are also encoded and decoded in the query part of the URL. This is vital for deep linking and differentiation for SEO. |
@passsy @goderbauer @jonahwilliams |
@mdebbar can you take a look at this and decide what's the best way to proceed here? Looks like it's waiting on feedback. I notice that flutter/flutter#55232 has been closed due to inactivity, but I don't have enough context to know whether that's due to this PR not having landed yet. If we do think we should proceed with this then we should probably revive that one. |
/// | ||
/// In order to use this [LocationStrategy] for an app, it needs to be set in | ||
/// [engine.window.locationStrategy.locationStrategy]: | ||
class PathLocationStrategy extends LocationStrategy { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to have a lot of duplicated code from the hashlocationstrategy. We should probably refactor out a mixin
This PR is the engine companion for flutter/flutter#55232, and should be closed for inactivity too. The problem with the approach of this PR is that app developers can't implement their own location strategies, they can only choose from the ones we provide. To solve that, we are going with a slightly different approach using JS interop. The PRs are still in draft mode because they were blocked by a JS interop issue for a while. The blocker has recently been fixed, so I'm planning to pick the PRs again and get them to the end line. |
This change adds another
flutter.web.usePathStrategy
dart define flag so that you can build Flutter Web with a different location strategy. This change needs to land first before flutter/flutter#55232, so that the flutter tool can change it's local web-server behaviour so that the browser is given index.html for previously unknown URLs.Example usage:
flutter build web --dart-define=flutter.web.usePathStrategy=true
Closes: flutter/flutter#33245 - Flutter_web navigation should provide a way to remove hash symbol(#)
/cc @jonahwilliams @yjbanov