Skip to content

Commit

Permalink
External links are not treated as relative urls
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexHalb committed Jul 27, 2020
1 parent 143ee61 commit af4a95a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/app/components/LinkModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
This link goes to <a target="_blank" :href="url">{{url}}</a>.
</span>
<button
class="btn link-button btn-primary w-100 mt-2"
class="btn link-button btn-primary w-100 mt-2 text-white"
style="left: 50%"
@click="openModal = false"
>
Expand Down
5 changes: 5 additions & 0 deletions src/app/tools/Markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ md.renderer.rules.link_open = function linkOpen(tokens: any, idx: any, options:
} else {
tokens[idx].attrs[classIndex][1] += ' external-link'; // replace value of existing attr
}

if (href.match(/(.+\.)+\w+(\/.)*/) && !href.match(/^.+:\/\//)) {
console.log(`http://${href}`, href);
tokens[idx].attrs[hrefIndex][1] = `http://${href}`;
}
}

return defaultRender(tokens, idx, options, env, self);
Expand Down

0 comments on commit af4a95a

Please sign in to comment.