it('should app.curl(obj)', async () => { const obj = urlparse(url + '/get_headers'); const result = await app.curl(obj, { dataType: 'json' }); assert(result.status === 200); assert(result.data.host === host); const obj2 = urlparse(url + '/get_headers'); // mock obj2.host obj2.host = null; const result2 = await app.curl(obj2, { dataType: 'json' }); assert(result2.status === 200); assert(result2.data.host === host); });
// We use `PUBLIC_URL` environment variable or "homepage" field to infer // "public path" at which the app is served. // Webpack needs to know it to put the right <script> hrefs into HTML even in // single-page apps that may serve index.html for nested URLs like /todos/42. // We can't use a relative path in HTML because we don't want to load something // like /todos/42/static/js/bundle.7289d.js. We have to know the root. function getServedPath(appPackageJson) { const publicUrl = getPublicUrl(appPackageJson); const servedUrl = envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '/'); return ensureSlash(servedUrl, true); }
// (publicKey -> cert) cache function verifyPublicKeyUrl(publicKeyUrl) { const parsedUrl = url.parse(publicKeyUrl); if (parsedUrl.protocol !== 'https:') { return false; } const hostnameParts = parsedUrl.hostname.split('.'); const length = hostnameParts.length; const domainParts = hostnameParts.slice(length - 2, length); const domain = domainParts.join('.'); return domain === 'apple.com'; }
// Helper to parse a pantheon site into a git url const getGitUrl = site => url.format({ auth: `codeserver.dev.${site.id}`, protocol: 'ssh:', slashes: true, hostname: `codeserver.dev.${site.id}.drush.in`, port: '2222', pathname: '/~/repository.git', })
function makeRequest(path, options) { options = options || {}; options.uri = url.resolve(server, path); options.timeout = 1000 * 60 * 2; // 2 Minutes return request(options); }
describe('safeParseURL()', () => { it('should return null if url invalid', () => { assert(utils.safeParseURL('https://eggjs.org%0a.com') === null); assert(utils.safeParseURL('/path/for') === null); }); it('should return parsed url', () => { assert(utils.safeParseURL('https://eggjs.org').hostname === 'eggjs.org'); assert(utils.safeParseURL('https://eggjs.org!.foo.com').hostname === 'eggjs.org!.foo.com'); }); });
function parseURL(URL) { if (typeof URL === 'string') { return url.parse(URL); } return undefined; }
it('should not cache ip', async () => { const obj = urlparse(url.replace('localhost', '127.0.0.1') + '/get_headers'); const result = await app.curl(obj, { dataType: 'json' }); assert(result.status === 200); assert(result.data.host === obj.host); assert(!app.httpclient.dnsCache.get('127.0.0.1')); });
/* * @TODO */ const setDockerHost = (hostname, port = 2376) => url.format({ protocol: 'tcp', slashes: true, hostname, port, })
// We use `PUBLIC_URL` environment variable or "homepage" field to infer // "public path" at which the app is served. // Webpack needs to know it to put the right <script> hrefs into HTML even in // single-page apps that may serve index.html for nested URLs like /todos/42. // We can't use a relative path in HTML because we don't want to load something // like /todos/42/static/js/bundle.7289d.js. We have to know the root. function getServedPath(appPackageJson) { const publicUrl = getPublicUrl(appPackageJson); const servedUrl = envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '/'); return ensureSlash(servedUrl, true); }
// We use `PUBLIC_URL` environment variable or "homepage" field to infer // "public path" at which the app is served. // Webpack needs to know it to put the right <script> hrefs into HTML even in // single-page apps that may serve index.html for nested URLs like /todos/42. // We can't use a relative path in HTML because we don't want to load something // like /todos/42/static/js/bundle.7289d.js. We have to know the root. function getServedPath(appPackageJson) { const publicUrl = getPublicUrl(appPackageJson); const servedUrl = envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '/'); return ensureSlash(servedUrl, true); }
// (publicKey -> cert) cache function verifyPublicKeyUrl(publicKeyUrl) { const parsedUrl = url.parse(publicKeyUrl); if (parsedUrl.protocol !== 'https:') { return false; } const hostnameParts = parsedUrl.hostname.split('.'); const length = hostnameParts.length; const domainParts = hostnameParts.slice(length - 2, length); const domain = domainParts.join('.'); return domain === 'apple.com'; }