Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): use regex instead of isAbsoluteUrl #2202

Merged
merged 11 commits into from Aug 22, 2019
2 changes: 1 addition & 1 deletion lib/utils/runOpen.js
Expand Up @@ -14,7 +14,7 @@ function runOpen(uri, options, log) {
}

const pageUrl =
options.openPage && isAbsoluteUrl(String(options.openPage))
options.openPage && isAbsoluteUrl(options.openPage)
? options.openPage
: `${uri}${options.openPage || ''}`;

Expand Down
43 changes: 43 additions & 0 deletions test/server/contentBase-option.test.js
Expand Up @@ -324,6 +324,49 @@ describe('contentBase option', () => {
expect(true).toBe(false);
}
});
it("Should not throw exception (local path with lower case first character & has '-')", (done) => {
try {
// eslint-disable-next-line no-unused-vars
server = new Promise((resolve, reject) => {
testServer.start(config, {
contentBase: 'c:absolutepath\tocontent-base',
Copy link
Member

Choose a reason for hiding this comment

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

Typo 😄

watchContentBase: true,
port: 2223,
});
resolve(testServer);
});

server.then((testServer) => {
testServer.close(() => {
done();
});
});
} catch (e) {
expect(true).toBe(false);
}
});
it("Should not throw exception (local path with upper case first character & has '-')", (done) => {
try {
// eslint-disable-next-line no-unused-vars
server = new Promise((resolve, reject) => {
testServer.start(config, {
contentBase: 'C:absolutepath\tocontent-base',
watchContentBase: true,
port: 2223,
});
resolve(testServer);
});

server.then((testServer) => {
testServer.close(() => {
done();
});
});
} catch (e) {
expect(true).toBe(false);
}
});

it('Should throw exception (array)', (done) => {
try {
// eslint-disable-next-line no-unused-vars
Expand Down