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

Properly resolve index.html and other entrypoint links #469

Merged
merged 3 commits into from
Aug 25, 2021

Conversation

bgoddar
Copy link
Contributor

@bgoddar bgoddar commented Aug 20, 2021

This PR fixes an issue where index.html and other entrypoint links in the extension would not properly resolve to workspace folders. This PR adds a setting to allow users to set the entrypoint of their site, otherwise it defaults to index.html. This causes links like "http://localhost:8080/" from the devtools to now properly resolve to "${workspacefolder}/index.html" It also prompts users to update this setting on cases where default entrypoint does not match a known file.

image

image

image

resolves #420

Copy link
Member

@hkal hkal left a comment

Choose a reason for hiding this comment

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

I've left one non-blocking comment.

src/utils.ts Outdated
@@ -478,6 +483,18 @@ export function replaceWebRootInSourceMapPathOverridesEntry(webRoot: string, ent
return entry;
}

export function addEntrypointIfNeeded(sourcePath: string, defaultEntrypoint: string): string {
try {
Copy link
Member

Choose a reason for hiding this comment

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

What in this codeblock causes an exception we can't anticipated? It's not clear to me why we need a try/catch if we aren't logging an exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, the new URL() call will throw if the passed in string isn't a valid url. I can't think of a case where that would be, but I added the try catch just to be safe.

I'd be open to letting it throw throw and then catching in the devtoolsPanel and reporting an error instead of attempting to open the file. I'll go ahead and make that change

Copy link

@mliao95 mliao95 left a comment

Choose a reason for hiding this comment

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

LGTM with one suggestion.

Discussed on a call. Would be good to have an error toast notification to suggest users to change the defaultEntrypoint setting if the source path is modified via the addEntrypointIfNeeded function and it still fails when trying to show the document.

@bgoddar
Copy link
Contributor Author

bgoddar commented Aug 23, 2021

Moving this back to draft. I want to rebase this off Vidal's incoming error message handling PR

@bgoddar bgoddar marked this pull request as draft August 23, 2021 17:28
@bgoddar bgoddar force-pushed the bgoddar/htmlLinkFix branch from edc044e to a740ae6 Compare August 25, 2021 19:36
@bgoddar bgoddar marked this pull request as ready for review August 25, 2021 20:02
@bgoddar bgoddar merged commit 47431f6 into main Aug 25, 2021
@bgoddar bgoddar deleted the bgoddar/htmlLinkFix branch August 25, 2021 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Initiator links in network tool don't work when using localhost
3 participants