File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,10 @@ function getUrl() {
7878 }
7979
8080 function getShortUrl () {
81- $ ch = curl_init ('https://quickchart.io/chart/create ' );
81+ if ($ this ->host != 'quickchart.io ' ) {
82+ throw new Exception ('Short URLs must use quickchart.io host ' );
83+ }
84+ $ ch = curl_init ($ this ->getRootEndpoint () . '/chart/create ' );
8285 $ postData = array (
8386 'backgroundColor ' => $ this ->backgroundColor ,
8487 'width ' => $ this ->width ,
@@ -105,7 +108,7 @@ function getShortUrl() {
105108 }
106109
107110 function toBinary () {
108- $ ch = curl_init (' https://quickchart.io /chart ' );
111+ $ ch = curl_init ($ this -> getRootEndpoint () . ' /chart ' );
109112 $ postData = array (
110113 'backgroundColor ' => $ this ->backgroundColor ,
111114 'width ' => $ this ->width ,
@@ -128,6 +131,10 @@ function toFile($path) {
128131 $ data = $ this ->toBinary ();
129132 file_put_contents ($ path , $ data );
130133 }
134+
135+ protected function getRootEndpoint () {
136+ return $ this ->protocol . ':// ' . $ this ->host . ': ' . $ this ->port ;
137+ }
131138}
132139
133- ?>
140+
You can’t perform that action at this time.
0 commit comments