File tree 1 file changed +13
-4
lines changed
1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 58
58
. replace ( / \/ b l o b \/ / , '/' ) . replace ( / \/ r a w \/ / , '/' ) ;
59
59
} ;
60
60
61
+ /**
62
+ * Reports an error directly in HTML.
63
+ * @param {string } msg - The error message to be reported to the user.
64
+ * @returns {void }
65
+ */
66
+ const reportError = function ( msg ) {
67
+ const errP = document . createElement ( 'p' ) ;
68
+ errP . innerHTML = msg ;
69
+ document . body . appendChild ( errP ) ;
70
+ throw new SyntaxError ( msg ) ;
71
+ } ;
72
+
61
73
/**
62
74
* If the first parameter is a URL to a file on a known git forge,
63
75
* returns the URL to the raw version of this file
73
85
const params = new URLSearchParams ( location . search ) ;
74
86
const previewFileUrl = params . get ( 'url' ) ;
75
87
if ( previewFileUrl === null ) {
76
- const errP = document . createElement ( 'p' ) ;
77
- errP . innerHTML = 'Please use "...?url=..." vs the old "...?..."!' ;
78
- document . body . appendChild ( errP ) ;
79
- throw new SyntaxError ( 'Missing required parameter "url"!' ) ;
88
+ reportError ( 'Missing required parameter "url"' ) ;
80
89
}
81
90
82
91
return rawifyForgeUrl ( previewFileUrl ) ;
You can’t perform that action at this time.
0 commit comments