@@ -10,10 +10,18 @@ function decodeLink(url) {
1010
1111 // save link data
1212
13+ const urlQuery = new URL ( url ) . searchParams ;
14+
1315 url = decodeURIComponent ( url ) ;
16+
17+
18+ const isEmbed = urlQuery . has ( 'embed' ) ;
19+
20+ const isLiveViewDisabled = ( urlQuery . get ( 'live' ) === 'false' || urlQuery . get ( 'l' ) === 'f' ) ;
1421
15- const isEmbed = url . endsWith ( '?embed=true' ) ;
16- if ( isEmbed ) url = url . slice ( 0 , - ( '?embed=true' . length ) ) ;
22+ // remove query from URL
23+ url = url . replace ( '?' + urlQuery . toString ( ) , '' ) ;
24+
1725
1826 const isDev = url . startsWith ( 'https://dev.cde.run/' ) ;
1927
@@ -23,6 +31,7 @@ function decodeLink(url) {
2331 const isGithub = url . startsWith ( 'https://github.com/' ) ;
2432 if ( isGithub ) url = url . slice ( 'https://github.com/' . length ) ;
2533
34+
2635 // if link is a Git URL
2736 if ( isGithub && url . endsWith ( '.git' ) ) {
2837
@@ -82,8 +91,10 @@ function decodeLink(url) {
8291 linkData . contents = linkData . contents . slice ( 0 , ( - lastEntry . length - 1 ) ) ;
8392
8493 // if linked file can be viewed live
85- if ( lastEntry . endsWith ( '.html' ) || lastEntry . endsWith ( '.svg' ) ||
86- lastEntry . endsWith ( '.md' ) ) {
94+ // and live view not disabled
95+ if ( ( lastEntry . endsWith ( '.html' ) || lastEntry . endsWith ( '.svg' ) ||
96+ lastEntry . endsWith ( '.md' ) )
97+ && ( isLiveViewDisabled === false ) ) {
8798
8899 // show file in live view
89100 linkData . openLive = true ;
0 commit comments