mirror of https://github.com/status-im/metro.git
Discard protocol, host, and port of URLs in bundle options
Summary: HTTP request URLs don’t include protocol, host and port. Stack frames URLs, on the other hand, contain full URLs. These full URLs are used to get the correct bundle to build the source map from. The method that creates option objects from URLs therefore now discards leading protocol, host and port to ensure that cached bundles can be reused for symbolication rather than triggering rebuilds. Reviewed By: jeanlauliac, cpojer Differential Revision: D4598077 fbshipit-source-id: 262df187bcdf7099011371e8b55ae692c6e1a942
This commit is contained in:
parent
7e8ab0d237
commit
6fa8dedfb5
|
@ -540,6 +540,15 @@ describe('processRequest', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('_getOptionsFromUrl', () => {
|
||||
it('ignores protocol, host and port of the passed in URL', () => {
|
||||
const short = '/path/to/entry-file.js??platform=ios&dev=true&minify=false';
|
||||
const long = `http://localhost:8081${short}`;
|
||||
expect(server._getOptionsFromUrl(long))
|
||||
.toEqual(server._getOptionsFromUrl(short));
|
||||
});
|
||||
});
|
||||
|
||||
// ensures that vital properties exist on fake request objects
|
||||
function scaffoldReq(req) {
|
||||
if (!req.headers) {
|
||||
|
|
|
@ -793,6 +793,8 @@ class Server {
|
|||
const symbolicatingLogEntry =
|
||||
log(createActionStartEntry('Symbolicating'));
|
||||
|
||||
debug('Start symbolication');
|
||||
|
||||
/* $FlowFixMe: where is `rowBody` defined? Is it added by
|
||||
* the `connect` framework? */
|
||||
Promise.resolve(req.rawBody).then(body => {
|
||||
|
@ -842,6 +844,7 @@ class Server {
|
|||
});
|
||||
}).then(
|
||||
stack => {
|
||||
debug('Symbolication done');
|
||||
res.end(JSON.stringify({stack: stack}));
|
||||
process.nextTick(() => {
|
||||
log(createActionEndEntry(symbolicatingLogEntry));
|
||||
|
@ -918,6 +921,7 @@ class Server {
|
|||
} {
|
||||
// `true` to parse the query param as an object.
|
||||
const urlObj = url.parse(reqUrl, true);
|
||||
|
||||
/* $FlowFixMe: `pathname` could be empty for an invalid URL */
|
||||
const pathname = decodeURIComponent(urlObj.pathname);
|
||||
|
||||
|
@ -931,9 +935,6 @@ class Server {
|
|||
return true;
|
||||
}).join('.') + '.js';
|
||||
|
||||
const sourceMapUrlObj = Object.assign({}, urlObj);
|
||||
sourceMapUrlObj.pathname = pathname.replace(/\.bundle$/, '.map');
|
||||
|
||||
// try to get the platform from the url
|
||||
/* $FlowFixMe: `query` could be empty for an invalid URL */
|
||||
const platform = urlObj.query.platform ||
|
||||
|
@ -948,7 +949,12 @@ class Server {
|
|||
const dev = this._getBoolOptionFromQuery(urlObj.query, 'dev', true);
|
||||
const minify = this._getBoolOptionFromQuery(urlObj.query, 'minify', false);
|
||||
return {
|
||||
sourceMapUrl: url.format(sourceMapUrlObj),
|
||||
sourceMapUrl: url.format({
|
||||
hash: urlObj.hash,
|
||||
pathname: pathname.replace(/\.bundle$/, '.map'),
|
||||
query: urlObj.query,
|
||||
search: urlObj.search,
|
||||
}),
|
||||
entryFile: entryFile,
|
||||
dev,
|
||||
minify,
|
||||
|
|
Loading…
Reference in New Issue