Skip to content

fix(cid): localhost should only be considered as proxy if prefix is c or v.#1289

Merged
erwinmombay merged 1 commit intoampproject:masterfrom
erwinmombay:proxy-change
Jan 7, 2016
Merged

fix(cid): localhost should only be considered as proxy if prefix is c or v.#1289
erwinmombay merged 1 commit intoampproject:masterfrom
erwinmombay:proxy-change

Conversation

@erwinmombay
Copy link
Copy Markdown
Member

No description provided.

@cramforce
Copy link
Copy Markdown
Member

Do the unit tests still go through the same code path?

@erwinmombay
Copy link
Copy Markdown
Member Author

@cramforce with this current code, i can't 100% guarantee that. i think there could certainly be an indirect use of the cid service in the tests that used to go through the getBaseCid path but would now go through the Promise.resolve path. (any test that had cid usage where url is localhost w/o v or c prefix).

im thinking of just removing the changes i made and doing this:

  if (url.origin.indexOf('http://localhost:') != 0) {
    assert(prefix == 'c' || prefix == 'v',
        'Unknown path prefix in url %s', url.href);
  }

in getSourceOrigin which fixes my localhost warning problems and would ensure all tests still go through the same code path.

@cramforce
Copy link
Copy Markdown
Member

I'm confused by the changeset that GH is showing now. Otherwise it was fine.

@jridgewell
Copy link
Copy Markdown
Contributor

This LGTM. What's the v prefix for?

@erwinmombay
Copy link
Copy Markdown
Member Author

@cramforce i dont think i was confident that the previous code wouldn't be forcing the tests into the Promise.resolve path (a test using localhost:8000/test for example). had to change from localDev since localDev also checks that the files come from dist or base (should we just remove that check in localDev?).

not sure what the v/c stands for, @cramforce can you shed some light on that one?

@erwinmombay erwinmombay force-pushed the proxy-change branch 2 times, most recently from a641501 to 21563f5 Compare January 5, 2016 16:50
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what we discussed was to instead make #isProxyOrigin only return true if the assert would not fail.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cramforce reverted to original change. PTAL

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cramforce PTAL. changed to check if localhost has prefix c/v

@cramforce
Copy link
Copy Markdown
Member

LGTM

erwinmombay added a commit that referenced this pull request Jan 7, 2016
fix(cid): localhost should only be considered as proxy if prefix is c or v.
@erwinmombay erwinmombay merged commit e3fd74b into ampproject:master Jan 7, 2016
@dparikh dparikh mentioned this pull request Oct 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants