@@ -152,18 +152,23 @@ class Kunai {
152152 // HTML in a local file system is directly opened in a Web browser,
153153 // "static/crsearch/crsearch.json" cannot be read using XHR due to the
154154 // CORS (cross-origin resource sharing) policy for the local files.
155- if ( / ^ f i l e : \/ \/ / . test ( current_script . src ) ) {
156- const url_kunai = current_script . getAttribute ( "src" )
157-
158- // When the current script file (kunai.js) is located in an expected
159- // path in the tree, we try to load the local database file
160- // "crsearch/crsearch.js" in JSONP format.
161- const url = url_kunai . replace ( / \b k u n a i \/ j s \/ k u n a i \. j s ( [ ? # ] .* ) ? $ / , "crsearch/crsearch.js" )
162- if ( url != url_kunai ) return url
163-
164- // Try to download "crsearch.json" from the project website.
165- if ( online_base_url )
166- return online_base_url + "static/crsearch/crsearch.json"
155+ try {
156+ if ( / ^ f i l e : \/ \/ / . test ( current_script . src ) ) {
157+ const url_kunai = current_script . getAttribute ( "src" )
158+
159+ // When the current script file (kunai.js) is located in an expected
160+ // path in the tree, we try to load the local database file
161+ // "crsearch/crsearch.js" in JSONP format.
162+ const url = url_kunai . replace ( / \b k u n a i \/ j s \/ k u n a i \. j s ( [ ? # ] .* ) ? $ / , "crsearch/crsearch.js" )
163+ if ( url != url_kunai ) return url
164+
165+ // Try to download "crsearch.json" from the project website.
166+ if ( online_base_url )
167+ return online_base_url + "static/crsearch/crsearch.json"
168+ }
169+ } catch ( e ) {
170+ this . log . warn ( 'Failed to handle file:// protocol:' , e )
171+ // フォールバックとして通常のURLを使用
167172 }
168173
169174 // Try to determine the position of crsearch.json
0 commit comments