Skip to content

Overly aggressive AutoLocation rootURL assertion #10201

@tomdale

Description

@tomdale

There are two invariants maintained by AutoLocation via assertions that have caused a regression in Skylight. I don't know exactly what change caused this to break, and I'm trying to untangle the thread, but the bottom line is I believe AutoLocation is too aggressive and should handle this case more gracefully.

The two invariants causing problems are:

  1. AutoLocation enforces that rootURL must always end with a slash /. So, for example, if we set the rootURL to /app, it will raise an exception unless we change it to /app/.
  2. AutoLocation verifies that the rootURL is contained in the URL inside _getHistoryPath(), and raises an exception if not (https://github.com/emberjs/ember.js/blob/master/packages/ember-routing/lib/location/auto_location.js#L240)

This is problematic because our Ember app is served by our Rails app, and links generated by Rails link to, you guessed it, /app (no trailing slash).

At some point, our app started throwing exceptions when hitting localhost:4200/app directly instead of /app/. Perversely, everything works fine if I comment out the above-linked assertion, so it seems like it's not doing much. (In that case, Ember automatically redirects to /app/ from /app.)

I don't know the most robust way to handle this case, but it seems like we should loosen the constraints on rootURL and automatically do the normalization in code, rather than pushing complexity to the user.

cc/ @cibernox @jayphelps

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions