vscode-live-server icon indicating copy to clipboard operation
vscode-live-server copied to clipboard

Inject code to last candidate

Open twhlynch opened this issue 1 year ago • 3 comments

Rather than injecting into the first match of "</body>" , it will inject into the last found occurrence of it. This will avoid overwriting code following the tag. Also works for the head regex.

PR Type

What kind of change does this PR introduce?

Fix injection candidate regex

[x] Bugfix
[ ] Feature
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other: <!-- Please describe: -->

What is the current behavior?

matches the first occurrence of a tag and overrides code

Issue Number: N/A (there were multiple issues referring to this issue)

What is the new behavior?

matches the last occurrence of a tag

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

twhlynch avatar Feb 26 '23 07:02 twhlynch

adjusting the head regex may not fix the issue, but the body fix will, and it is the most commonly used / reported issue

twhlynch avatar Feb 26 '23 07:02 twhlynch

I'm facing an issue due to this. Is there any plan to merge this fix? For example:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        "</body>"
    </script>
</body>
</html>

Results in: image

williamthome avatar Sep 17 '23 13:09 williamthome

I'm facing an issue due to this. Is there any plan to merge this fix?

Highly doubt it. The extension hasn't been updated for over a year.

twhlynch avatar Sep 17 '23 13:09 twhlynch