Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
one more try
Browse files Browse the repository at this point in the history
  • Loading branch information
Jain, Sneha T authored and Jain, Sneha T committed Jan 4, 2019
1 parent f8e0018 commit 72d4b15
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 25 deletions.
9 changes: 2 additions & 7 deletions src/utils/sources-tree/addToTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,9 @@ function traverseTree(
tree: TreeDirectory,
debuggeeHost: ?string
): TreeNode {
const parts = url.path.split("/").filter(p => p !== "");
const parts = url.path.split("/").filter((p, i) => p !== "" || i < 2);

/* handle absolute paths from webpack bundles */
if (url.isAbsolutePath) {
parts.unshift("");
}

parts.unshift(url.group);
parts[0] = url.group;

let path = "";
return parts.reduce((subTree, part, index) => {
Expand Down
8 changes: 3 additions & 5 deletions src/utils/sources-tree/getURL.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import type { Source } from "../../types";
export type ParsedURL = {
path: string,
group: string,
filename: string,
isAbsolutePath: boolean
filename: string
};

const urlMap: WeakMap<Source, ParsedURL> = new WeakMap();
Expand All @@ -30,7 +29,7 @@ export function getFilenameFromPath(pathname?: string) {
}

const NoDomain = "(no domain)";
const def = { path: "", group: "", filename: "", isAbsolutePath: false };
const def = { path: "", group: "", filename: "" };

function _getURL(source: Source, defaultDomain: string): ParsedURL {
const { url } = source;
Expand Down Expand Up @@ -61,8 +60,7 @@ function _getURL(source: Source, defaultDomain: string): ParsedURL {
...def,
path: pathname,
filename,
group: `${protocol}//`,
isAbsolutePath: pathname.startsWith("//")
group: `${protocol}//`
};

case "about:":
Expand Down
15 changes: 2 additions & 13 deletions src/utils/sources-tree/tests/getUrl.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,6 @@ describe("getUrl", () => {
expect(urlObject.group).toBe("webpack://");
});

it("sets absolutepath flag for webpack absolute paths", () => {
const urlObject = getURL(
createMockSource({
url: "webpack:////src/component.jsx"
})
);
expect(urlObject.isAbsolutePath).toBe(true);
});

it("creates a group name for angular", () => {
const urlObject = getURL(
createMockSource({
Expand Down Expand Up @@ -126,8 +117,7 @@ describe("getUrl", () => {
expect(url).toEqual({
filename: "baz.js",
group: "example.com",
path: "/foo/bar/baz.js",
isAbsolutePath: false
path: "/foo/bar/baz.js"
});
});

Expand All @@ -147,8 +137,7 @@ describe("getUrl", () => {
expect(url).toEqual({
filename: "baz.js",
group: "example.com",
path: "/foo/bar/baz.js",
isAbsolutePath: false
path: "/foo/bar/baz.js"
});
});
});
Expand Down

0 comments on commit 72d4b15

Please sign in to comment.