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

fix: Ensured no errors pops up when a space is given infront of export default #34703

Open
wants to merge 1 commit into
base: release
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { jsEditor } from "../../../../support/Objects/ObjectsCore";

describe("JS Editor cypress test case", { tags: ["@tag.JS"] }, () => {
it("1. Bug : should accept spaces before export default", () => {
jsEditor.CreateJSObject(
` export default {
myFun1: () => {
function hi(a,b) {
console.log(a,b);
}
hi(1,2);
},
myFun2: async () => {
//use async-await or promises
}
}`,
{
completeReplace: true,
toRun: false,
prettify: false,
},
);

jsEditor.AssertSelectedFunction("myFun1");
});
});
2 changes: 1 addition & 1 deletion app/client/src/workers/Evaluation/JSObject/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const getUpdatedLocalUnEvalTreeAfterJSUpdates = (
return localUnEvalTree;
};

export const validJSBodyRegex = new RegExp(/^export default[\s]*?({[\s\S]*?})/);
export const validJSBodyRegex = new RegExp(/^\s*export default[\s]*?({[\s\S]*?})/);

/**
* Here we parse the JSObject and then determine
Expand Down