Skip to content

Conversation

@stephanwlee
Copy link
Contributor

When it contains leading slash, it creates url like "//data/..." which
is interpretted as an absolute url.

When it contains leading slash, it creates url like "//data/..." which
is interpretted as an absolute url.
});

it('ignores leading slash in dataDir', () => {
const router = createRouter('/data/', /*demoMode=*/false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't demoMode be true if these are tests for demoMode? Not sure it's necessary to test separately though given that this isn't really critical when in demo mode.

ext: string, params?: URLSearchParams): string {

const url = new URL(`${window.location.origin}/${pathPrefix}${path}`);
const url = new URL(`${window.location.origin}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

The URL wrapper is working pretty indirectly here, apparently by doing some implicit normalization when the properties are set (like adding a leading slash to the path). Can you add a comment to explain that?

'/data/plugin/scalars/scalar');
});

it('ignores leading slash in dataDir', function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

These tests logically are more testing createRouter() than pluginRoute(), and seem like either way they should be grouped with the existing test for "removes trailing slash from base route".

Can you also add an explicit test for the case where it adds a leading slash when there isn't one there? This is implicitly tested by the "removes trailing slash" test but it'd be better to have an explicit test. Or it could be merged with the test here as something like "ensures at least one leading slash in dataDir".

'/data/plugin/scalars/scalar');
});

it('ignores leading slash in dataDir', function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we standardize the naming on "pathPrefix" as you used for createProdPath(), rather than "dataDir"? It's confusing that it's inconsistent between parts of the code and code vs tests, and "pathPrefix" both is clearer and matches the flag naming.

Nothing except these two files seems to reference dataDir, so I think just a find-replace would suffice.

Copy link
Contributor

@nfelt nfelt left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the cleanup!

@stephanwlee stephanwlee merged commit f5127b9 into tensorflow:master Oct 30, 2018
@stephanwlee stephanwlee deleted the url branch October 30, 2018 23:43
@nfelt nfelt mentioned this pull request Nov 27, 2018
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.

2 participants