mirror of
https://github.com/vee1e/mitmproxy.git
synced 2026-09-01 18:27:18 +00:00
Fix bug scripts in Mitmweb (#6668)
#### Description This PR should fix issue: #6002 #### Checklist - [x] I have updated tests where applicable. - [ ] I have added an entry to the CHANGELOG. --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
3ba4b65ecd
commit
240a286b2a
3 changed files with 21 additions and 4 deletions
|
|
@ -97,6 +97,6 @@ describe("StringOption Component", () => {
|
|||
it("should handle onChange", () => {
|
||||
let mockEvent = { target: { value: "a\nb\nc\n" } };
|
||||
tree.props.onChange(mockEvent);
|
||||
expect(onChangeFn).toBeCalledWith(["a", "b", "c", ""]);
|
||||
expect(onChangeFn).toBeCalledWith(["a", "b", "c"]);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -99,11 +99,26 @@ StringSequenceOption.propTypes = {
|
|||
|
||||
function StringSequenceOption({ value, onChange, ...props }) {
|
||||
const height = Math.max(value.length, 1);
|
||||
|
||||
const [textAreaValue, setTextAreaValue] = React.useState(value.join("\n"));
|
||||
|
||||
const handleChange = (e) => {
|
||||
const newValue = e.target.value;
|
||||
setTextAreaValue(newValue); //save in the state the current input value
|
||||
onChange(
|
||||
//we send to the backend only the strings that are not empty
|
||||
newValue
|
||||
.split("\n")
|
||||
.map((line) => line.trim())
|
||||
.filter((line) => line !== "")
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<textarea
|
||||
rows={height}
|
||||
value={value.join("\n")}
|
||||
onChange={(e) => onChange(e.target.value.split("\n"))}
|
||||
value={textAreaValue}
|
||||
onChange={handleChange}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,9 @@ export default function reducer(state = defaultState, action): OptionsState {
|
|||
|
||||
export async function pureSendUpdate(option: Option, value, dispatch) {
|
||||
try {
|
||||
const response = await fetchApi.put("/options", { [option]: value });
|
||||
const response = await fetchApi.put("/options", {
|
||||
[option]: value,
|
||||
});
|
||||
if (response.status === 200) {
|
||||
dispatch(optionsEditorActions.updateSuccess(option));
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue