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

Relative url addresses in <a> and <img> support #153

Closed
alp1396 opened this issue Sep 7, 2019 · 2 comments · Fixed by #532
Closed

Relative url addresses in <a> and <img> support #153

alp1396 opened this issue Sep 7, 2019 · 2 comments · Fixed by #532

Comments

@alp1396
Copy link

alp1396 commented Sep 7, 2019

Is it possible to add an "BaseURL" option?
In my case all the links and images comes from API with relative path href="/some/url/there".
So, it would be nice to prefix them with custom String param.

@alp1396
Copy link
Author

alp1396 commented Sep 7, 2019

Temporary solution for images that works for me. Using customRender() to override processing.

Html(
  data: '<img src="/an/relative/image.jpg">',
  useRichText: false,
  customRender: (node, children) {
    if (node is dom.Element) {
      switch (node.localName) {
        case "img":
          if (node.attributes.containsKey('src')) {
            return Image('http://mydomain.com' + node.attributes['src']);
          }
      }
    }
  },
);

Note that you need to add dart:html package to get dom.Element check.

@Sub6Resources
Copy link
Owner

Pull request #146 will fix this issue for images. Relative urls in the a tag should be able to be handled in the onLinkTap function.

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

Successfully merging a pull request may close this issue.

2 participants