Development

#1656 (_compute_public_path fix - not placing .js after ?var=blah calls.)

You must first sign up to be able to contribute.

Ticket #1656 (closed defect: fixed)

Opened 6 years ago

Last modified 6 years ago

_compute_public_path fix - not placing .js after ?var=blah calls.

Reported by: Daniel.Graetzer Assigned to: fabien
Priority: minor Milestone: 1.0.2
Component: helpers Version: 1.0.0
Keywords: _compute_public_path Cc:
Qualification:

Description

Here is a bit of a fix for AssetsHelper?.php

We have a consistant problem of when adding parameters to javascript files.. eg.. blah.js?var=cats is outputting as blah.js?var=cats.js

So here's the fix for _compute_public_path.

function _compute_public_path($source, $dir, $ext, $absolute = false)
{
  if (strpos($source, ‘://’))
  {
    return $source;
  }
 
  $request = sfContext::getInstance()->getRequest();
  $sf_relative_url_root = $request->getRelativeUrlRoot();
  if (strpos($source, ‘/’) !== 0)
  {
    $source = $sf_relative_url_root.‘/’.$dir.‘/’.$source;
  }
 
  $tail = ”;
  if(strpos($source, ‘?’) !== false )
  {
    list($source, $tail) = explode(‘?’, $source, 2);
  }
 
  if (strpos(basename($source), ‘.’) === false)
  {
    $source .= ‘.’.$ext;
  }
 
  if(strlen($tail) > 0)
  {
    $source .= ‘?’. $tail;
  }
 
  if ($sf_relative_url_root && strpos($source, $sf_relative_url_root) !== 0)
  {
    $source = $sf_relative_url_root.$source;
  }
 
  if ($absolute)
  {
    $source = ‘http’.($request->isSecure() ? ’s’ : ”).‘://’.$request->getHost().$source;
  }
 
  return $source;
}

Change History

04/13/07 08:26:54 changed by fabien

  • milestone set to 1.0.2.

04/13/07 09:08:09 changed by fabien

  • status changed from new to closed.
  • resolution set to fixed.

(In [3775]) fixed _compute_public_path() when using a query string (closes #1656)

04/13/07 09:09:23 changed by fabien

(In [3776]) fixed _compute_public_path() when using a query string (closes #1656)