@@ -69,6 +69,13 @@ async function authorizeToken(options: PublishOptions) {
6969 throwUnableToPublish ( "the git repository does not have a remote origin" ) ;
7070 }
7171
72+ // validate that we can deduce the site url
73+ if ( ! ghContext . siteUrl ) {
74+ throwUnableToPublish (
75+ "the git repository is not hosted on github.com and does not have a CNAME file" ,
76+ ) ;
77+ }
78+
7279 // good to go!
7380 return Promise . resolve ( anonymousAccount ( ) ) ;
7481}
@@ -184,24 +191,19 @@ async function publish(
184191 message :
185192 "Deploying gh-pages branch to website (this may take a few minutes)" ,
186193 } , async ( ) => {
187- try {
188- const noJekyllUrl = joinUrl ( ghContext . siteUrl ! , ".nojekyll" ) ;
189- while ( true ) {
190- await sleep ( 2000 ) ;
191- const response = await fetch ( noJekyllUrl ) ;
192- if ( response . status === 200 ) {
193- if ( ( await response . text ( ) ) . trim ( ) === deployId ) {
194- verified = true ;
195- await sleep ( 2000 ) ;
196- break ;
197- }
198- } else if ( response . status !== 404 ) {
194+ const noJekyllUrl = joinUrl ( ghContext . siteUrl ! , ".nojekyll" ) ;
195+ while ( true ) {
196+ await sleep ( 2000 ) ;
197+ const response = await fetch ( noJekyllUrl ) ;
198+ if ( response . status === 200 ) {
199+ if ( ( await response . text ( ) ) . trim ( ) === deployId ) {
200+ verified = true ;
201+ await sleep ( 2000 ) ;
199202 break ;
200203 }
204+ } else if ( response . status !== 404 ) {
205+ break ;
201206 }
202- } catch {
203- // ignore errors -- this might be an alternate url scheme or auth error
204- // (in this case verified will be 'false` and no browser will be shown)
205207 }
206208 } ) ;
207209 }
@@ -406,8 +408,10 @@ function siteUrl(dir: string, originUrl: string) {
406408 / h t t p s : \/ \/ ( [ ^ \/ ] + ) \/ ( [ ^ \/ ] + ) \/ ( [ ^ . ] + ) \. g i t / ,
407409 ) ;
408410
409- if ( match ) {
410- const server = match [ 1 ] . replace ( "github.com" , "github.io" ) ;
411+ const kGithubCom = "github.com" ;
412+ const kGithubIo = "github.io" ;
413+ if ( match && match [ 1 ] . includes ( kGithubCom ) ) {
414+ const server = match [ 1 ] . replace ( kGithubCom , kGithubIo ) ;
411415 return `https://${ match [ 2 ] } .${ server } /${ match [ 3 ] } /` ;
412416 }
413417 }
0 commit comments