Skip to content

Commit

Permalink
fix: convert relative to absolute urls
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Jun 15, 2020
1 parent e92fbdb commit ef8e221
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
13 changes: 6 additions & 7 deletions packages/hover-vanilla/demo/index.html
Expand Up @@ -72,13 +72,12 @@ <h3 class="mt3 f3 fw6">Demos</h3>
<script src="./dist/microlink.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function (event) {
const links = Array.prototype.slice.call(document.querySelectorAll('a')).map(el => {
if (el.href.startsWith('/')) {
el.setAttribute('href', new URL(el.href, window.location.href).toString())
}
return el
})
.filter(el => el.href.startsWith('http') && !el.href.includes('localhost'))
const links = Array.prototype.slice.call(document.querySelectorAll('a'))
.map(el => {
el.href = new URL(el.href).toString()
return el
})
.filter(el => el.href.startsWith('http') && !el.href.includes('localhost'))

microlinkHover(links, {
media: ['iframe', 'video', 'audio', 'image', 'logo']
Expand Down
10 changes: 5 additions & 5 deletions packages/hover-vanilla/demo/joshwcomeau.html
Expand Up @@ -435,12 +435,12 @@
<script src="./dist/microlink.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function (event) {
const links = Array.prototype.slice.call(document.querySelectorAll('.Link__ExternalLink-sc-68e6gi-0')).map(el => {
if (el.href.startsWith('/')) {
el.setAttribute('href', new URL(el.href, window.location.href).toString())
}
const links = Array.prototype.slice.call(document.querySelectorAll('a'))
.map(el => {
el.href = new URL(el.href).toString()
return el
}).filter(el => el.href.startsWith('http') && !el.href.includes('localhost'))
})
.filter(el => el.href.startsWith('http') && !el.href.includes('localhost'))

microlinkHover(links, {
media: ['iframe', 'video', 'audio', 'image', 'logo']
Expand Down

0 comments on commit ef8e221

Please sign in to comment.