File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ Import the file into your vue app entry point to register a global directive or
1212```
1313import Vue from 'vue';
1414import App from './App';
15- import Xframe from 'vue-xframe';
15+ import { xframe } from 'vue-xframe';
1616
1717//Global directive registration
1818Vue.directive('xframe', xframe);
@@ -24,7 +24,7 @@ new Vue({
2424
2525//Local directive registration
2626directives: {
27- Xframe
27+ xframe
2828}
2929
3030```
Original file line number Diff line number Diff line change 77import Vue from 'vue' ;
88
99export 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 ( / ( h t t p s ? : \/ \/ ) ? [ \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 ( / < h e a d ( [ ^ > ] * ) > / i, `<head$1>
1719 <base href="${ url } ">
1820 <script>
You can’t perform that action at this time.
0 commit comments