diff --git a/devtools/client/debugger/src/components/PrimaryPanes/tests/SourcesTree.spec.js b/devtools/client/debugger/src/components/PrimaryPanes/tests/SourcesTree.spec.js index 0e98724997cf..15defca42e52 100644 --- a/devtools/client/debugger/src/components/PrimaryPanes/tests/SourcesTree.spec.js +++ b/devtools/client/debugger/src/components/PrimaryPanes/tests/SourcesTree.spec.js @@ -373,7 +373,7 @@ function generateDefaults(overrides: Object) { ), "server1.conn13.child1/42/originalSource-sha": createMockSource( "server1.conn13.child1/42/originalSource-sha", - "http://mdn.com/four.js", + "http://mdn.com/four.js [original]", false ), "server1.conn13.child1/42": createMockSource( diff --git a/devtools/client/debugger/src/components/PrimaryPanes/tests/__snapshots__/SourcesTree.spec.js.snap b/devtools/client/debugger/src/components/PrimaryPanes/tests/__snapshots__/SourcesTree.spec.js.snap index 2ad707e03340..4f3bf23418bf 100644 --- a/devtools/client/debugger/src/components/PrimaryPanes/tests/__snapshots__/SourcesTree.spec.js.snap +++ b/devtools/client/debugger/src/components/PrimaryPanes/tests/__snapshots__/SourcesTree.spec.js.snap @@ -179,11 +179,11 @@ exports[`SourcesTree on receiving new props updates highlighted items updates hi "isExtension": false, "isPrettyPrinted": false, "isWasm": false, - "relativeUrl": "http://mdn.com/four.js", - "url": "http://mdn.com/four.js", + "relativeUrl": "http://mdn.com/four.js [original]", + "url": "http://mdn.com/four.js [original]", }, - "name": "four.js", - "path": "FakeThread/mdn.com/four.js", + "name": "four.js%20[original]", + "path": "FakeThread/mdn.com/four.js%20[original]", "type": "source", }, Object { @@ -273,11 +273,11 @@ exports[`SourcesTree on receiving new props updates highlighted items updates hi "isExtension": false, "isPrettyPrinted": false, "isWasm": false, - "relativeUrl": "http://mdn.com/four.js", - "url": "http://mdn.com/four.js", + "relativeUrl": "http://mdn.com/four.js [original]", + "url": "http://mdn.com/four.js [original]", }, - "name": "four.js", - "path": "FakeThread/mdn.com/four.js", + "name": "four.js%20[original]", + "path": "FakeThread/mdn.com/four.js%20[original]", "type": "source", }, Object { diff --git a/devtools/client/debugger/src/utils/sources-tree/addToTree.js b/devtools/client/debugger/src/utils/sources-tree/addToTree.js index 24ed990a0489..d08f57c777ca 100644 --- a/devtools/client/debugger/src/utils/sources-tree/addToTree.js +++ b/devtools/client/debugger/src/utils/sources-tree/addToTree.js @@ -36,10 +36,9 @@ function createNodeInTree( } /* - * Look for the child directory + * Look for the child node * 1. if it exists return it * 2. if it does not exist create it - * 3. if it is a file, replace it with a directory */ function findOrCreateNode( parts: string[], @@ -69,7 +68,7 @@ function findOrCreateNode( const childIsFile = !nodeHasChildren(child); // if we have a naming conflict, we'll create a new node - if (child.type === "source" || (!childIsFile && addedPartIsFile)) { + if (childIsFile != addedPartIsFile) { // pass true to findNodeInContents to sort node by url const { index: insertIndex } = findNodeInContents( subTree, @@ -79,7 +78,7 @@ function findOrCreateNode( } // if there is no naming conflict, we can traverse into the child - return child; + return (child: any); } /* @@ -132,7 +131,7 @@ function addSourceToNode( ): Source | TreeNode[] { const isFile = !isPathDirectory(url.path); - if (node.type == "source") { + if (node.type == "source" && !isFile) { throw new Error(`Unexpected type "source" at: ${node.name}`); }