Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

remove last slash if exists from prepare_url private method #6

Open
wants to merge 2 commits into from

1 participant

@jipipayo

sometimes the a user puts a url with the ending backslash, this fix removes this backslash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 18 additions and 9 deletions.
  1. +18 −9 lib/shopify_api.php
View
27 lib/shopify_api.php
@@ -109,15 +109,18 @@ function sendToAPI($url, $request = 'GET', $xml = array()){
return $ch->loadString($data);
}
- function gzdecode($data){
- $g = tempnam(GZIP_PATH, 'ff');
- @file_put_contents($g, $data);
- ob_start();
- readgzfile($g);
- $d = ob_get_clean();
- unlink($g);
- return $d;
- }
+ if (! function_exists('gzdecode')) { //compatibility with php 5.4 (now implements native gzdecode)
+ function gzdecode($data){
+ $g = tempnam(GZIP_PATH, 'ff');
+ @file_put_contents($g, $data);
+ ob_start();
+ readgzfile($g);
+ $d = ob_get_clean();
+ unlink($g);
+ return $d;
+ }
+ }
+
class ApplicationCharge{
private $prefix = "/application_charges";
@@ -1364,6 +1367,12 @@ private function prepare_url($url){
if (substr_count($url, '.myshopify.com') == 0 && substr_count($url, '.com') == 0){
$url .= '.myshopify.com';
}
+
+ //remove last slash if exists
+ if ($url[strlen($url) - 1] == '/') {
+ $url = substr($url, 0, -1);
+ }
+
return $url;
}
Something went wrong with that request. Please try again.