@@ -103,18 +103,12 @@ module.exports = (options) => {
103103 } ;
104104
105105 const hasValidCertificate = ( pagesDomain ) => {
106- if ( options . domain . includes ( pagesDomain . domain ) ) {
107- if ( pagesDomain . certificate ) {
108- if ( ! pagesDomain . certificate . expired ) {
109- const validUntil = pki . certificateFromPem ( pagesDomain . certificate . certificate ) . validity . notAfter ;
110- const expiresInMS = validUntil . getTime ( ) - new Date ( ) . getTime ( ) ;
111- return expiresInMS > DEFAULT_EXPIRATION_IN_MS ;
112- }
113- }
114- return false ;
106+ if ( pagesDomain . certificate && ! pagesDomain . certificate . expired ) {
107+ const validUntil = pki . certificateFromPem ( pagesDomain . certificate . certificate ) . validity . notAfter ;
108+ const expiresInMS = validUntil . getTime ( ) - new Date ( ) . getTime ( ) ;
109+ return expiresInMS > DEFAULT_EXPIRATION_IN_MS ;
115110 }
116- // We do not care about the current domain, as we did not give it in the arguments
117- return true ;
111+ return false ;
118112 } ;
119113
120114 const createPagesDomains = ( repo ) => {
@@ -130,10 +124,14 @@ module.exports = (options) => {
130124 return ! pagesDomainsNames . includes ( domain ) ;
131125 } ) ;
132126
127+ const domainsToCheck = pagesDomains . filter ( pagesDomain => {
128+ return options . domain . includes ( pagesDomain . domain ) ;
129+ } ) ;
130+
133131 const needsNoRenewal =
134132 ! options . forceRenewal &&
135133 domainsToCreate . length === 0 &&
136- pagesDomains . every ( hasValidCertificate ) ;
134+ domainsToCheck . every ( hasValidCertificate ) ;
137135
138136 if ( needsNoRenewal ) {
139137 console . log ( `All domains (${ options . domain . join ( ', ' ) } ) have a valid certificate (expiration in more than ${ DEFAULT_EXPIRATION } )` ) ;
0 commit comments