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

Update browser launch regex to support non-default logging frameworks #3842

Merged
merged 5 commits into from
Jun 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions debugger-launchjson.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ The default launch.json template (as of C# extension v1.20.0) for ASP.NET Core p
```json
"serverReadyAction": {
"action": "openExternally",
"pattern": "^\\s*Now listening on:\\s+(https?://\\S+)"
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
}
```

Expand All @@ -66,8 +66,7 @@ Notes about this:
5. The way this works is that VS Code will scrape the output which is set to the console. If a line
matches the pattern, it will launch a browser against the URL which was 'captured' by the pattern.
Here is an explanation of what the pattern does:
* `^`: This indicates that the pattern should only be matched against the beginning of a line.
* `\\s*` : Matches zero or more whitespace characters. Note that `\s` indicates a whitespace character, but because this is in a json string, the `\` needs to be escaped, hence `\\s`.
* `\\b` : Matches on a word boundery. Note that `\b` indicates a word boundary, but because this is in a json string, the `\` needs to be escaped, hence `\\b`.
* `Now listening on:` : This is a string literal, meaning that the next text must be `Now listening on:`.
* `\\s+` : Matches one or more space characters.
* `(` : This is the beginning of a 'capture group' -- this indicates which region of text will be saved and used to launch the browser.
Expand All @@ -87,7 +86,7 @@ If you want to ignore the URL from the console output, you can remove the
```json
"serverReadyAction": {
"action": "openExternally",
"pattern": "^\\s*Now listening on:\\s+https?://\\S",
"pattern": "\\bNow listening on:\\s+https?://\\S",
"uriFormat": "http://localhost:1234"
}
```
Expand All @@ -97,7 +96,7 @@ If you want to use the port number from the console output, but not the host nam
```json
"serverReadyAction": {
"action": "openExternally",
"pattern": "^\\s*Now listening on:\\s+http://\\S+:([0-9]+)",
"pattern": "\\bNow listening on:\\s+http://\\S+:([0-9]+)",
"uriFormat": "http://localhost:%s"
}
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2013,7 +2013,7 @@
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "^\"^\\\\\\\\s*Now listening on:\\\\\\\\s+(https?://\\\\\\\\S+)\""
"pattern": "\\\\bNow listening on:\\\\s+(https?://\\\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
Expand Down
2 changes: 1 addition & 1 deletion src/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ export function createWebLaunchConfiguration(programPath: string, workingDirecto
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
"serverReadyAction": {
"action": "openExternally",
"pattern": "^\\\\s*Now listening on:\\\\s+(https?://\\\\S+)"
"pattern": "\\\\bNow listening on:\\\\s+(https?://\\\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
Expand Down