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

[Bug] markdown to document with image from storage #721

Closed
g-apparence opened this issue Feb 20, 2024 · 1 comment · Fixed by #795
Closed

[Bug] markdown to document with image from storage #721

g-apparence opened this issue Feb 20, 2024 · 1 comment · Fixed by #795

Comments

@g-apparence
Copy link

g-apparence commented Feb 20, 2024

Bug Description

Markdown to document doesn't work on image with properties after extension.

When you have an image from for example firebase storage it has an url like
https://firebase.com/filename.jpg?alt=media&token=823990382903

How to Reproduce

Create a markdown with an image hosted on a S3 with the token in url

Expected Behavior

We should have an image

Operating System

all

AppFlowy Editor Version(s)

2.3.2

Screenshots

No response

Additional Context

This is where the code is wrong

file: document_markdown_decoder.dart
line : 208

if (imageRegex.hasMatch(line.trim())) {
      final filePath = extractImagePath(line.trim());
      // checking if filepath is present or if the filepath is an image or not
      if (filePath == null ||
          !['.png', '.jpg', 'jpeg'].contains(p.extension(filePath))) {
        return paragraphNode(text: line.trim());
      }
      return imageNode(url: filePath);
    }

Here is a solution to fix this

final filePath = extractImagePath(line.trim());
if (filePath == null) {
  return paragraphNode(text: line.trim());
}
final uri = Uri.parse(filePath);
final fileExtension = p.extension(uri.path);

// checking if filepath is present or if the filepath is an image or not
if (!['.png', '.jpg', 'jpeg'].contains(fileExtension)) {
  return paragraphNode(text: line.trim());
}
@LucasXu0
Copy link
Collaborator

@g-apparence Thanks for reporting. Can you submit a PR to fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants