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

Uri::convertUrl not working with Windows paths #2197

Open
hundblue opened this issue Sep 24, 2018 · 0 comments
Open

Uri::convertUrl not working with Windows paths #2197

hundblue opened this issue Sep 24, 2018 · 0 comments

Comments

@hundblue
Copy link

The Uri::convertUrl function does not correctly handle paths prefixed by drive letters, like e.g. E:/grav/user/pages/02.foo. As a consequence, the directory-relative links do not work in Windows.

The demo code below shows the problem. The call to Uri::parseUrl splits E:/grav/user/pages/03.bar to a "scheme" E and the remaing path /grav/user/pages/03.bar.

<?php
use Grav\Common\Utils;
use Grav\Common\Uri;

$page_path = 'E:/grav/user/pages/02.foo'; // $page->path();
$url_path  = '../03.bar';
$path            = $page_path.'/'.$url_path;
$normalized_path = Utils::normalizePath ($path);
$url_bits        = Uri::parseUrl($normalized_path);
$full_path       = $url_bits['path'];

$inspect = [
  'path'            => $path,
  'normalized_path' => $normalized_path,
  'url_bits'        => $url_bits,
  'full_path'       => $full_path,
];
/*
path => "E:/grav/user/pages/02.foo/../03.bar" (35)
normalized_path => "E:/grav/user/pages/03.bar" (25)
url_bits => array (2)
    scheme => "E"
    path => "/grav/user/pages/03.bar" (23)
full_path => "/grav/user/pages/03.bar" (23)
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants