Skip to content

[go_router] Doesn't support "/abc", "/ABC" as two different paths #169809

Closed
flutter/packages
#9426

Description

@deegoy2

What package does this bug report belong to?

go_router

What target platforms are you seeing this bug on?

Web

Have you already upgraded your packages?

Yes

Dependency versions

pubspec.lock
packages:
  go_router:
    dependency: "direct main"
    description:
      name: go_router
      sha256: "0b1e06223bee260dee31a171fb1153e306907563a0b0225e8c1733211911429a"
      url: "https://pub.dev"
    source: hosted
    version: "15.1.2"

Steps to reproduce

  1. go_router configuration:
final GoRouter _router = GoRouter(
  initialLocation: '/',
  routes: <RouteBase>[
    GoRoute(path: '/', builder: (_, _) => Home(),),
    GoRoute(path: '/abc', builder: (_, _) => Home(),),
    GoRoute(path: '/ABC', builder: (_, _) => Home(),),
  ],
);
  1. Run the app.
  2. Open "/abc", it should work.
  3. Open "/ABC", throws an exception.

Expected results

The part of the URL after the domain name (the "path" or "directory" part) is generally case-sensitive on most web servers, especially those running on Unix-like operating systems, so expectation is that all three endpoints should render Home().

Actual results

"/ABC" throws

======== Exception caught by widgets library =======================================================
The following assertion was thrown building DefaultSelectionStyle:
Assertion failed: file:///C:/Users/user/AppData/Local/Pub/Cache/hosted/pub.dev/go_router-15.1.2/lib/src/match.dart:245:12
uriPathToCompare.startsWith(newMatchedLocationToCompare)
is not true

Code sample

Code sample
final GoRouter _router = GoRouter(
  initialLocation: '/',
  routes: <RouteBase>[
    GoRoute(path: '/', builder: (_, _) => Home(),),
    GoRoute(path: '/abc', builder: (_, _) => Home(),),
    GoRoute(path: '/ABC', builder: (_, _) => Home(),),
  ],
);

Screenshots or Videos

Screenshots / Video demonstration

Image

Logs

Logs
======== Exception caught by widgets library =======================================================
The following assertion was thrown building DefaultSelectionStyle:
Assertion failed: file:///C:/Users/user/AppData/Local/Pub/Cache/hosted/pub.dev/go_router-15.1.2/lib/src/match.dart:245:12
uriPathToCompare.startsWith(newMatchedLocationToCompare)
is not true

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.32.0, on Microsoft Windows [Version 10.0.22631.5189], locale en-US)
[√] Windows Version (11 Pro 64-bit, 23H2, 2009)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[√] Android Studio (version 2024.3.2)
[√] IntelliJ IDEA Community Edition (version 2023.1)
[√] VS Code (version 1.100.2)
[√] Connected device (3 available)
[√] Network resources

Activity

  1. changed the title [-]Doesn't support "/abc", "/ABC" as two different paths[/-] [+][go_router] Doesn't support "/abc", "/ABC" as two different paths[/+] on May 31, 2025
  2. darshankawar commented on Jun 2, 2025

    @darshankawar
    Member

    @deegoy2
    I tried with below runnable code sample with which I didn't see the reported error. Please provide updated code that triggers the error. I tried with latest stable version (3.32.1).

    runnable code
    
    import 'package:flutter/material.dart';
    import 'package:go_router/go_router.dart';
    
    void main() {
      runApp(const MyApp());
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({super.key});
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp.router(routerConfig: router);
      }
    }
    
    
    final router = GoRouter(
      initialLocation: '/',
      routes: <RouteBase>[
        GoRoute(path: '/', builder: (_, _) => HomeScreen(),),
        GoRoute(path: '/abc', builder: (_, _) => HomeScreen(),),
        GoRoute(path: '/ABC', builder: (_, _) => HomeScreen(),),
      ],
    );
    
    
    class HomeScreen extends StatefulWidget {
    
      @override
      State<HomeScreen> createState() => _HomeScreenState();
    
    }
    
    class _HomeScreenState extends State<HomeScreen> {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: Center(
            child: Text('test')
          ),
        );
      }
    }
    
    
    
  3. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jun 2, 2025
  4. iapicca commented on Jun 2, 2025

    @iapicca

    @darshankawar

    try this

    navigate to "lower case" and observe the error
    cc @deegoy2 in case I missed something

  5. deegoy2 commented on Jun 2, 2025

    @deegoy2
    Author

    Thank you @iapicca, your example shows the error for nested routes.
    Created this to show the same error for multiple base routes.

  6. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jun 2, 2025
  7. darshankawar commented on Jun 3, 2025

    @darshankawar
    Member

    Thanks for the upated repos. Using below one, I was able to replicate the reported behavior on latest sdk versions.

    runnable code
    
    import 'package:flutter/material.dart';
    import 'package:go_router/go_router.dart';
    
    void main() => runApp(const MyApp());
    
    final _router = GoRouter(
      routes: [
        GoRoute(
          path: '/',
          builder: (context, state) => const HomePage(),
          routes: [
            GoRoute(path: 'Page', builder: (context, state) => const Page1()),
            GoRoute(path: 'page', builder: (context, state) => const Page2()),
          ],
        ),
      ],
    );
    
    class MyApp extends StatelessWidget {
      const MyApp({super.key});
    
      @override
      Widget build(context) => MaterialApp.router(routerConfig: _router);
    }
    
    class HomePage extends StatelessWidget {
      const HomePage({super.key});
    
      @override
      Widget build(context) => Scaffold(
        appBar: AppBar(title: const Text('Home')),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              ElevatedButton(
                onPressed: () => context.go('/Page'),
                child: const Text('Upper Case'),
              ),
              const SizedBox(height: 40),
              ElevatedButton(
                onPressed: () => context.go('/page'),
                child: const Text('Lower Case'),
              ),
            ],
          ),
        ),
      );
    }
    
    class Page1 extends StatelessWidget {
      const Page1({super.key});
    
      @override
      Widget build(context) => Scaffold(
        appBar: AppBar(title: const Text('Page')),
        body: const Center(
          child: FlutterLogo(
            size: 200,
            style: FlutterLogoStyle.stacked,
            textColor: Colors.red,
          ),
        ),
      );
    }
    
    class Page2 extends StatelessWidget {
      const Page2({super.key});
    
      @override
      Widget build(context) => Scaffold(
        appBar: AppBar(title: const Text('page')),
        body: const Center(
          child: FlutterLogo(
            size: 200,
            style: FlutterLogoStyle.stacked,
            textColor: Colors.green,
          ),
        ),
      );
    }
    
    
    stable : 3.32.1
    master : 3.33.0-1.0.pre.305
    
  8. 4 remaining items

  9. iapicca commented on Jun 24, 2025

    @iapicca

    that was really fast <3 @ValentinVignal

  10. added
    r: fixedIssue is closed as already fixed in a newer version
    on Jun 25, 2025
  11. github-actions commented on Jul 9, 2025

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  12. locked as resolved and limited conversation to collaborators on Jul 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listfound in release: 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: go_routerThe go_router packagepackageflutter/packages repository. See also p: labels.platform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions