Skip to content

Commit

Permalink
Merge pull request #28485 from storybookjs/fix-regex-escaping
Browse files Browse the repository at this point in the history
Addon Controls: Fix saving on Windows
  • Loading branch information
valentinpalkovic authored Jul 8, 2024
2 parents 41053bf + df1a772 commit d749cf2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions code/core/src/core-server/utils/save-story/save-story.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ const parseArgs = (args: string): Record<string, any> =>
// Removes extra newlines between story properties. See https://github.com/benjamn/recast/issues/242
// Only updates the part of the code for the story with the given name.
const removeExtraNewlines = (code: string, name: string) => {
const anything = '(.|\r\n|\r|\n)'; // Multiline match for any character.
const newline = '(\r\n|\r|\n)'; // Either newlines or carriage returns may be used in the file.
const anything = '([\\s\\S])'; // Multiline match for any character.
const newline = '(\\r\\n|\\r|\\n)'; // Either newlines or carriage returns may be used in the file.
const closing = newline + '};' + newline; // Marks the end of the story definition.
const regex = new RegExp(
// Looks for an export by the given name, considers the first closing brace on its own line
Expand Down

0 comments on commit d749cf2

Please sign in to comment.