From 641c3105542437bfe8eda5f91eca0bddea8dd824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=9F=9A=E5=AD=90?= <76462613+uuznn@users.noreply.github.com> Date: Sun, 24 Jan 2021 20:55:38 +0800 Subject: [PATCH] Explicitly use HTTPS for Vendors (#187) --- scripts/events/lib/vendors.js | 6 +++--- scripts/helpers/engine.js | 6 +++--- scripts/helpers/font.js | 2 +- test/helpers/font.js | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/events/lib/vendors.js b/scripts/events/lib/vendors.js index 26e335e..4bda1c0 100644 --- a/scripts/events/lib/vendors.js +++ b/scripts/events/lib/vendors.js @@ -25,9 +25,9 @@ module.exports = hexo => { const { name, version, file, alias, unavailable } = value; const links = { local : url_for.call(hexo, `lib/${name}/${file}`), - jsdelivr: `//cdn.jsdelivr.net/npm/${name}@${version}/${file}`, - unpkg : `//unpkg.com/${name}@${version}/${file}`, - cdnjs : `//cdnjs.cloudflare.com/ajax/libs/${alias || name}/${version}/${file.replace(/^(dist|lib|)\/(browser\/|)/, '')}` + jsdelivr: `https://cdn.jsdelivr.net/npm/${name}@${version}/${file}`, + unpkg : `https://unpkg.com/${name}@${version}/${file}`, + cdnjs : `https://cdnjs.cloudflare.com/ajax/libs/${alias || name}/${version}/${file.replace(/^(dist|lib|)\/(browser\/|)/, '')}` }; let { plugins = 'jsdelivr' } = vendors; if (plugins === 'cdnjs' && unavailable && unavailable.includes('cdnjs')) plugins = 'jsdelivr'; diff --git a/scripts/helpers/engine.js b/scripts/helpers/engine.js index e4a0597..8855e8f 100644 --- a/scripts/helpers/engine.js +++ b/scripts/helpers/engine.js @@ -20,9 +20,9 @@ hexo.extend.helper.register('next_js', function(file, pjax = false) { const { internal } = this.theme.vendors; const links = { local : this.url_for(`${this.theme.js}/${file}`), - jsdelivr: `//cdn.jsdelivr.net/npm/hexo-theme-next@${next_version}/source/js/${file}`, - unpkg : `//unpkg.com/hexo-theme-next@${next_version}/source/js/${file}`, - cdnjs : `//cdnjs.cloudflare.com/ajax/libs/hexo-theme-next/${next_version}/${file}` + jsdelivr: `https://cdn.jsdelivr.net/npm/hexo-theme-next@${next_version}/source/js/${file}`, + unpkg : `https://unpkg.com/hexo-theme-next@${next_version}/source/js/${file}`, + cdnjs : `https://cdnjs.cloudflare.com/ajax/libs/hexo-theme-next/${next_version}/${file}` }; const src = links[internal] || links.local; return ``; diff --git a/scripts/helpers/font.js b/scripts/helpers/font.js index ba8f018..5c46090 100644 --- a/scripts/helpers/font.js +++ b/scripts/helpers/font.js @@ -7,7 +7,7 @@ module.exports = function() { if (!config || !config.enable) return ''; const fontStyles = ':300,300italic,400,400italic,700,700italic'; - const fontHost = config.host || '//fonts.googleapis.com'; + const fontHost = config.host || 'https://fonts.googleapis.com'; // Get a font list from config let fontFamilies = []; diff --git a/test/helpers/font.js b/test/helpers/font.js index 27d660f..7119e10 100644 --- a/test/helpers/font.js +++ b/test/helpers/font.js @@ -5,7 +5,7 @@ const Hexo = require('hexo'); const hexo = new Hexo(); const fontStyles = ':300,300italic,400,400italic,700,700italic'; -const fontHost = '//fonts.googleapis.com'; +const fontHost = 'https://fonts.googleapis.com'; describe('font', () => { const nextFont = require('../../scripts/helpers/font').bind(hexo);