-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Closed
flutter/engine
#42598Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.f: routesNavigator, Router, and related APIs.Navigator, Router, and related APIs.platform-webWeb applications specificallyWeb applications specifically
Description
With the HashUrlStrategy, we add the hash fragment for all pages, including the home page (i.e. routeName = "/"). This means the landing page of the app always has a trailing /#/ in the URL (e.g. https://gallery.flutter.dev/#/).
One thing we can do to improve this is to have a special case for the / and the empty route name such that they don't add the hash fragment to the URL.
Users can already do this in their apps:
import 'package:flutter/material.dart';
import 'package:flutter_web_plugins/url_strategy.dart';
class MyUrlStrategy extends HashUrlStrategy {
@override
String prepareExternalUrl(String internalUrl) {
final String externalUrl = super.prepareExternalUrl(internalUrl);
if (externalUrl.endsWith('#/')) {
return externalUrl.substring(0, externalUrl.length - 2);
}
return externalUrl;
}
}
void main() {
setUrlStrategy(MyUrlStrategy());
runApp(MyApp());
}This issue is for making this the default behavior of HashUrlStrategy. cc @johnpryan @kevmoo
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.f: routesNavigator, Router, and related APIs.Navigator, Router, and related APIs.platform-webWeb applications specificallyWeb applications specifically