Skip to content

Commit 3add245

Browse files
committed
fix(jsfiddle): inline embedding of jsfiddle having / in url
1 parent 475a2a4 commit 3add245

6 files changed

Lines changed: 35 additions & 26 deletions

File tree

demo/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
<h1>Loading embed.js in a block</h1>
3434
<div id="url" class="block">
35-
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Itaque consectetur iure culpa reiciendis repudiandae vitae quae temporibus eum fugit, porro accusamus https://github.com/ritz078/embed.js quis quas sapiente, deleniti! Suscipit excepturi ipsa nobis corrupti.
35+
Lorem ipsum dolor sit amet https://jsfiddle.net/ritz078/n5dL6ogd/4/ , consectetur adipisicing elit. Itaque consectetur iure culpa reiciendis repudiandae vitae quae temporibus eum fugit, porro accusamus https://github.com/ritz078/embed.js quis quas sapiente, deleniti! Suscipit excepturi ipsa nobis corrupti.
3636
</div>
3737
<div id="block">
3838

@@ -74,7 +74,7 @@ <h1>Loading embed.js in a block</h1>
7474
// openGraphEndpoint:'https://opengraph.io/api/1.0/site/${url}',
7575
openGraphExclude:['github'],
7676
googleAuthKey:'AIzaSyCqFouT8h5DKAbxlrTZmjXEmNBjC69f0ts',
77-
// inlineEmbed:'all',
77+
inlineEmbed:'all',
7878
marked:true,
7979
link:true,
8080
onOpenGraphFetch:function(data){

src/embed.js

Lines changed: 18 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/embed.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/modules/code/jsfiddle.es6

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import Base from '../base.es6'
22

33
export default class JsFiddle extends Base {
4-
constructor(input, output, options, embeds) {
5-
super(input, output, options, embeds);
6-
this.regex = /jsfiddle.net\/[a-zA-Z0-9_]+\/[a-zA-Z0-9_]+/gi;
7-
this.service = 'jsfiddle';
8-
}
4+
constructor(input, output, options, embeds) {
5+
super(input, output, options, embeds);
6+
this.regex = /jsfiddle.net\/[a-zA-Z0-9_]+\/[a-zA-Z0-9_\/]+/gi;
7+
this.service = 'jsfiddle';
8+
}
99

10-
template(id) {
11-
return ejs.template.jsFiddle(id, this.options) || `<div class="ejs-embed ejs-jsfiddle"><iframe height="${this.options.codeEmbedHeight}" src="http://${id}/embedded"></iframe></div>`
12-
}
10+
template(id) {
11+
id = id[id.length - 1] == '/' ? id.slice(0, - 1) : id;
12+
id = (id.indexOf('//') !== -1) ? id : `//${id}`;
13+
return ejs.template.jsFiddle(id, this.options) || `<div class="ejs-embed ejs-jsfiddle"><iframe height="${this.options.codeEmbedHeight}" src="${id}/embedded"></iframe></div>`
14+
}
1315
}
1416

src/js/modules/url.es6

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export default class Url{
1111
var config = this.options.linkOptions;
1212
return this.input.replace(this.urlRegex,(match)=>{
1313
let extension = match.split('.')[match.split('.').length - 1];
14+
match = ((match[match.length-1] == '/') ? match.slice(0, -1) : match);
1415
if(config.exclude.indexOf(extension) === -1){
1516
return ejs.template.url(match, this.options) || `<a href="${toUrl(match)}" rel="${config.rel}" target="${config.target}">${match}</a>`;
1617
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/**
2+
* Created by ritz078 on 10/01/16.
3+
*/

0 commit comments

Comments
 (0)