diff options
| author | RblSb <msrblsb@gmail.com> | 2021-08-13 06:28:13 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2021-08-13 06:28:13 +0300 |
| commit | 5b908e914ebfeedb2895f5de1b9167a6ce12c136 (patch) | |
| tree | 14521fa2dd63c24afc219db90714e2a1509d5034 | |
| parent | f972d4b7b1c6a69ab20cd2aee5a43df702796075 (diff) | |
Fix local subs
closes #28
| -rw-r--r-- | build/server.js | 4 | ||||
| -rw-r--r-- | res/client.js | 5 | ||||
| -rw-r--r-- | src/client/players/RawSubs.hx | 5 | ||||
| -rw-r--r-- | src/server/HttpServer.hx | 8 |
4 files changed, 16 insertions, 6 deletions
diff --git a/build/server.js b/build/server.js index 013e3c4..1e842ca 100644 --- a/build/server.js +++ b/build/server.js @@ -3573,7 +3573,7 @@ server_HttpServer.init = function(dir,customDir,allowLocalRequests) { server_HttpServer.allowLocalRequests = allowLocalRequests; }; server_HttpServer.serveFiles = function(req,res) { - var url = req.url; + var url = decodeURI(req.url); if(url == "/") { url = "/index.html"; } @@ -3705,7 +3705,7 @@ server_HttpServer.proxyUrl = function(req,res) { server_HttpServer.proxyRequest = function(url,req,res,fn) { var url1; try { - url1 = new js_node_url_URL(global.decodeURI(url)); + url1 = new js_node_url_URL(decodeURI(url)); } catch( _g ) { return null; } diff --git a/res/client.js b/res/client.js index 75e3448..b0953ae 100644 --- a/res/client.js +++ b/res/client.js @@ -2819,7 +2819,10 @@ client_players_RawSubs.loadSubs = function(item,video) { if(client_JsApi.hasSubtitleSupport(ext)) { return; } - var url = "/proxy?url=" + encodeURI(item.subs); + var url = encodeURI(item.subs); + if(!StringTools.startsWith(url,"/")) { + url = "/proxy?url=" + url; + } switch(ext) { case "ass": client_players_RawSubs.parseAss(video,url); diff --git a/src/client/players/RawSubs.hx b/src/client/players/RawSubs.hx index a8cbc98..aa77bf8 100644 --- a/src/client/players/RawSubs.hx +++ b/src/client/players/RawSubs.hx @@ -22,7 +22,10 @@ class RawSubs { final ext = PathTools.urlExtension(item.subs); // do not load subs if there is custom plugin if (JsApi.hasSubtitleSupport(ext)) return; - final url = '/proxy?url=${encodeURI(item.subs)}'; + var url = encodeURI(item.subs); + if (!url.startsWith("/")) { + url = '/proxy?url=$url'; + } switch ext { case "ass": diff --git a/src/server/HttpServer.hx b/src/server/HttpServer.hx index 2076336..1198ca1 100644 --- a/src/server/HttpServer.hx +++ b/src/server/HttpServer.hx @@ -50,7 +50,7 @@ class HttpServer { } public static function serveFiles(req:IncomingMessage, res:ServerResponse):Void { - var url = req.url; + var url = decodeURI(req.url); if (url == "/") url = "/index.html"; var filePath = dir + url; final ext = Path.extension(filePath).toLowerCase(); @@ -183,7 +183,7 @@ class HttpServer { fn:(req:IncomingMessage) -> Bool ):Null<ClientRequest> { final url = try { - new URL(js.Node.global.decodeURI(url)); + new URL(decodeURI(url)); } catch (e) return null; if (url.host == req.headers["host"]) return null; final options = { @@ -215,4 +215,8 @@ class HttpServer { if (contentType == null) return "application/octet-stream"; return contentType; } + + static inline function decodeURI(data:String):String { + return js.Syntax.code("decodeURI({0})", data); + } } |
