2
0
Эх сурвалжийг харах

Merge pull request #20536 from Mugen87/dev44

Examples: Clean up.
Mr.doob 4 жил өмнө
parent
commit
e6ca8a47a4
1 өөрчлөгдсөн 13 нэмэгдсэн , 2 устгасан
  1. 13 2
      examples/index.html

+ 13 - 2
examples/index.html

@@ -58,6 +58,7 @@
 		const previewsToggler = document.getElementById( 'previewsToggler' );
 
 		const links = {};
+		const validRedirects = new Map();
 		const container = document.createElement( 'div' );
 
 		let selected = null;
@@ -87,14 +88,24 @@
 					container.appendChild( link );
 
 					links[ file ] = link;
+					validRedirects.set( file, file + '.html' );
 
 				}
 
 			}
 
-			if ( window.location.hash !== '' && links[ window.location.hash.substring( 1 ) ] ) {
+			if ( window.location.hash !== '' ) {
 
-				loadFile( window.location.hash.substring( 1 ) );
+				const file = window.location.hash.substring( 1 );
+
+				// use a predefined map of redirects to avoid untrusted URL redirection due to user-provided value
+
+				if ( validRedirects.has( file ) === true ) {
+
+					selectFile( file );
+					viewer.src = validRedirects.get( file );
+
+				}
 
 			}