Skip to content

Commit c21f6a3

Browse files
author
Bruno Paolillo
committed
bugfix
1 parent 5c8eb12 commit c21f6a3

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Import the file into your vue app entry point to register a global directive or
1212
```
1313
import Vue from 'vue';
1414
import App from './App';
15-
import Xframe from 'vue-xframe';
15+
import { xframe } from 'vue-xframe';
1616
1717
//Global directive registration
1818
Vue.directive('xframe', xframe);
@@ -24,7 +24,7 @@ new Vue({
2424
2525
//Local directive registration
2626
directives: {
27-
Xframe
27+
xframe
2828
}
2929
3030
```

index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
import Vue from 'vue';
88

99
export const xframe = {
10-
bind(el, binding, vnode) {
11-
let url = binding.value;
12-
if( url && url.startsWith('https://www') ) {
10+
update(el, binding, vnode) {
11+
const url = binding.value;
12+
const pattern = new RegExp(/(https?:\/\/)?[\w\-~]+(\.[\w\-~]+)+(\/[\w\-~]*)*(#[\w\-]*)?(\?.*)?/);
13+
if( pattern.test(url) ) {
1314
fetch(`https://cors-anywhere.herokuapp.com/${url}`)
1415
.then( (res) => res.text() )
1516
.then( (data) => {
17+
console.log(data);
1618
let iframeContent = data.replace(/<head([^>]*)>/i, `<head$1>
1719
<base href="${url}">
1820
<script>

0 commit comments

Comments
 (0)