Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

html5 mode with mismatching base href causes "TypeError: Cannot read property 'replace' of undefined" error in location.js #13565

Closed

Description

@jamlee1

Looking at the latest version of location.js (https://github.com/angular/angular.js/blob/4412fe238f37f79a2017ee7b20ba089c0acd73e9/src/ng/location.js)

If the tag does not match the actual href, $$parseLinkUrl will miss all the conditions and rewrittenUrl will not be defined, which means this.$$parse will not be called and $$absUrl will not be set.

Later on line 902 (

if (trimEmptyHash($location.absUrl()) != trimEmptyHash(initialUrl)) {
), trimEmptyHash($location.absUrl()) will be called in a condition, which will end up having trimEmptyHash call .replace on undefined, so we end up halting with:

TypeError: Cannot read property 'replace' of undefined

Activity

  1. Narretz commented on Dec 17, 2015

    @Narretz
    Contributor

    I'm not sure I understand the problem. In what case would the base tag not match the actual href?

  2. added this to the Purgatory milestone on Dec 17, 2015
  3. jamlee1 commented on Jan 4, 2016

    @jamlee1
    Author

    In my case, the html was being served on multiple domains. Granted, we can correct that base url, but it still shouldn't cause a javascript error in angular.

  4. OverZealous commented on Feb 23, 2016

    @OverZealous

    I agree, this shouldn't cause an unknown error. This is happening to us, and we couldn't see it until production, and it simply killed the page. Having such a low-level JS error seems like something that should have feedback.

    (It was a weird case in our situation, too, a production-only url rewrite that triggered an error.)

  5. gkalpak commented on Jun 3, 2016

    @gkalpak
    Member

    Should be fixed by #14488.

  6. modified the milestones: , Purgatory on Jun 3, 2016
  7. added a commit that references this issue on Jun 6, 2016
    294d679
  8. added a commit that references this issue on Sep 28, 2024
    b9ac336
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions