Skip to content

Commit

Permalink
Merge pull request #942 from savanainc/fix/941
Browse files Browse the repository at this point in the history
Fix: Path resolution strategy for Flutter Web hosted outside of base path (issue #941)
  • Loading branch information
jacobaraujo7 authored May 23, 2024
2 parents 0f7f8ad + 98c9188 commit 07d7e8b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,26 @@

import 'dart:html';

import 'package:flutter_modular/flutter_modular.dart';
import 'package:flutter_web_plugins/url_strategy.dart';

import 'url_service.dart';

class WebUrlService extends UrlService {
@override
String? getPath() => resolvePath(window.location.href);
String? getPath() {
final href = window.location.href;

if (urlStrategy is HashUrlStrategy) {
if (href.endsWith(Modular.initialRoute)) {
return Modular.initialRoute;
} else if (href.contains('#')) {
return href.split('#').last;
}
}

return resolvePath(href);
}
}

UrlService create() {
Expand Down
2 changes: 2 additions & 0 deletions flutter_modular/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ dependencies:
result_dart: ">=1.0.4 <2.0.0"
flutter:
sdk: flutter
flutter_web_plugins:
sdk: flutter

dev_dependencies:
flutterando_analysis: ^0.0.2
Expand Down

0 comments on commit 07d7e8b

Please sign in to comment.