]> Untitled Git - lemmy-ui.git/commitdiff
Fix suggested title " " spaces (#2037)
authormaxime.io <maxime.de.visscher@gmail.com>
Mon, 7 Aug 2023 12:39:44 +0000 (14:39 +0200)
committerGitHub <noreply@github.com>
Mon, 7 Aug 2023 12:39:44 +0000 (12:39 +0000)
* Fix imported title &nbsp spaces

* Update src/shared/components/post/post-form.tsx

Co-authored-by: SleeplessOne1917 <abias1122@gmail.com>
* Fix lint issue

---------

Co-authored-by: SleeplessOne1917 <abias1122@gmail.com>
src/shared/components/post/post-form.tsx

index 6c8862862fe9dc4e28134e389caf91baf983f42a..7b379263390195e6ba03243de0727f7fcf0b2486 100644 (file)
@@ -582,8 +582,10 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
       case "loading":
         return <Spinner />;
       case "success": {
-        const suggestedTitle = this.state.metadataRes.data.metadata.title;
-
+        // Clean up the title of any extra whitespace and replace &nbsp; with a space
+        const suggestedTitle = this.state.metadataRes.data.metadata.title
+          ?.trim()
+          .replace(/\s+/g, " ");
         return (
           suggestedTitle && (
             <button