Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UniformResourceLocator::findResource seems to fail with query parameters #7

Open
alexweissman opened this issue Mar 25, 2016 · 3 comments

Comments

@alexweissman
Copy link

findResource seems to have trouble resolving URIs that contain query parameters. For example, this seems to work fine:

$locator = new UniformResourceLocator(MY_BASE_DIR);
$locator->addPath('assets', '', 'assets');
echo $locator->findResource('images/favicon.ico', false);
// prints "assets/images/favicon.ico"

However if I do this:

$locator = new UniformResourceLocator(MY_BASE_DIR);
$locator->addPath('assets', '', 'assets');
echo $locator->findResource('images/favicon.ico?v=2', false);
// prints the empty string

Not sure if this is the intended behavior.

@mahagr
Copy link
Contributor

mahagr commented Mar 25, 2016

Its not meant to be used with URLs; it just locates files from the filesystem.

@alexweissman
Copy link
Author

Fair enough. However, in many applications (including Grav) there is a relationship between relative file paths and relative URLs. Is there an alternative preferred way to build URLs? Or, should I just do something like:

$locator->findResource('images/favicon.ico', false) . '?v=2';

@mahagr
Copy link
Contributor

mahagr commented Mar 29, 2016

For urls there's twig function called url() (both in Grav and Gantry), which uses streams internally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants