Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

Commit

Permalink
Оптимизированы регекспы
Browse files Browse the repository at this point in the history
  • Loading branch information
xtrafrancyz committed Jul 19, 2017
1 parent d76a802 commit e50f28a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion conf/nginx.conf
Expand Up @@ -51,7 +51,7 @@ http {
error_page 301 302 307 = @handle_vkcom_doc_redirect;
}

location ~ ^/_/((pu\.)?vk\.com|([a-z0-9-]+)\.(userapi\.com|vk-cdn\.net|vkuserlive\.com|vkuservideo\.net|vk\.me))/(.*)$ {
location ~ ^/_/((pu\.)?vk\.com|([a-z0-9-]+)\.(userapi\.com|vk-cdn\.net|vk\.me|vkuser(live|video|audio)\.(net|com)))/(.*)$ {
rewrite /_/([^/]+)/(.*) /$2 break;
proxy_pass https://$1;
proxy_redirect https://$1/ /;
Expand Down
4 changes: 2 additions & 2 deletions lib/handler/url-replacer.js
Expand Up @@ -5,7 +5,7 @@ var config = require.main.require('./config');
var escapedAssetsDomain = config.domain.assets.replace('/', '\\/');
var apiReplaces = [
[ // Ссылки на картинки, музыку и другой контент
/"https:\\\/\\\/(pu\.vk\.com|[-a-z0-9]+\.(?:userapi\.com|vk-cdn\.net|vkuservideo\.net|vkuservideo\.com|vkuserlive\.com|vkuserlive\.net|vkuseraudio\.com|vkuseraudio\.net|vk\.me))\\\/([^"]+)/g,
/"https:\\\/\\\/(pu\.vk\.com|[-a-z0-9]+\.(?:userapi\.com|vk-cdn\.net|vk\.me|vkuser(?:live|video|audio)\.(?:net|com)))\\\/([^"]+)/g,
'"https:\\/\\/' + escapedAssetsDomain + '\\/$1\\/$2'
],
[ // Плейлисты для видеозаписей подгружаются с vk.com, в которых нужно подменять ссылки на сами видеозаписи
Expand Down Expand Up @@ -42,7 +42,7 @@ var apiUrlReplaces = [
}
];

var vkcomHls = /https:\/\/([-a-z0-9]+\.(?:vk-cdn\.net|userapi\.com|vkuservideo\.net|vkuservideo\.com|vkuserlive\.com|vkuserlive\.net|vk\.me))\//g;
var vkcomHls = /https:\/\/([-a-z0-9]+\.(?:userapi\.com|vk-cdn\.net|vk\.me|vkuser(?:live|video)\.(?:net|com)))\//g;

module.exports.transform = function(response, req, res) {
let raw = response.raw;
Expand Down

0 comments on commit e50f28a

Please sign in to comment.