Skip to content

Commit de9e44b

Browse files
committed
Merge branch 'master' of https://github.com/Nodge/lessphp
Conflicts: lessc.inc.php
2 parents ad26c2c + ad20a69 commit de9e44b

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,9 @@ output run this:
9494

9595
For more help, run `plessc --help`
9696

97+
### This fork ([nodge/lessphp][5])
98+
99+
The only change in this fork is the ability to change relative paths according to path to root .less file. (Fixes [#119][6]).
100+
101+
[5]: https://github.com/Nodge/lessphp/
102+
[6]: https://github.com/leafo/lessphp/issues/119

lessc.inc.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class lessc {
5252

5353
public $importDisabled = false;
5454
public $importDir = '';
55-
55+
5656
public $allowUrlRewrite = true; // rewrite urls relative to imported files
5757
public $baseUrlPath = null;
5858

@@ -804,10 +804,14 @@ protected function rewriteUrls($url) {
804804

805805
if ($baseImportDir === $lastImportDir)
806806
return $url;
807-
807+
808+
$arguments = null;
809+
if(strpos($url,'?') !== false)
810+
list($url, $arguments) = explode('?', $url);
811+
808812
$urlPath = realpath($lastImportDir.DIRECTORY_SEPARATOR.$url);
809813
if ($urlPath === false)
810-
return $url;
814+
return $arguments ? $url.'?'.$arguments : $url;
811815

812816
$baseArray = explode(DIRECTORY_SEPARATOR, $baseImportDir);
813817
$urlArray = explode(DIRECTORY_SEPARATOR, $urlPath);
@@ -823,9 +827,9 @@ protected function rewriteUrls($url) {
823827
$newUrl = str_repeat('../', count($baseArray) - $i);
824828
$newUrl .= implode('/', array_slice($urlArray, $i));
825829

826-
return $newUrl;
830+
return $arguments ? $newUrl.'?'.$arguments : $newUrl;
827831
}
828-
832+
829833
protected function lib_isnumber($value) {
830834
return $this->toBool($value[0] == "number");
831835
}

0 commit comments

Comments
 (0)