Skip to content

Commit

Permalink
fix: allow to define with or without trailing slash inside DEFAULT_WW…
Browse files Browse the repository at this point in the history
…W_PATH
  • Loading branch information
coolcodemy committed Feb 14, 2021
1 parent 51cf03d commit 9c46e1b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,6 @@ You probably didn't like the idea of having `www` folder inside this cloned repo

To change this, you need to update `.env` file and `DEFAULT_WWW_PATH` to a new path, let say your Desktop. Make sure to use absolute path when defining `DEFAULT_WWW_PATH`. Give it a reload (`butler reload`) and check whether your site still registered with Valet, using `butler parked` or `butler links`.


**WARNING!!** When changing `DEFAULT_WWW_PATH`, you must end the path with `/`. E.g: `/var/www/` and not `/var/www`.

### Laravel Queue

**[Need better documentation]**
Expand Down
33 changes: 17 additions & 16 deletions bin/butler
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,23 @@ function generate_ca {
fi
}

function get_workdir {
www_path=$(get_env_value DEFAULT_WWW_PATH)
www_path=${www_path%/}

if test "${CURRENTDIR##$www_path}" != "$CURRENTDIR"; then
workdir=${CURRENTDIR//$www_path/}

if [ "$workdir" == "" ]; then
workdir="/"
fi

echo "/var/www$workdir"
else
echo "/var/www"
fi
}

function get_tld {
# We dont want to use jq. so... KISS
cat $BUTLERRUNPATH/$VALET_HOME/config.json | tr { '\n' | tr , '\n' | tr } '\n' | grep "tld" | awk -F'"' '{print $4}'
Expand Down Expand Up @@ -209,22 +226,6 @@ function get_env_value {
echo $VALUE
}

function get_workdir {
www_path=$(get_env_value DEFAULT_WWW_PATH)

if [[ $CURRENTDIR/ = $www_path/* ]]; then
workdir=${CURRENTDIR//$www_path/}

if [ "$workdir" == "" ]; then
workdir="/"
fi

echo "/var/www$workdir"
else
echo "/var/www"
fi
}

# Verify operating system is supported... We add it here in case we wanted to support Linux and Windows too
case "${UNAMEOUT}" in
Darwin*) MACHINE=mac;;
Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fi

if [ ! -f .env ]; then
cp ./stubs/.env .env
sed -i '' "s|REPLACEME|$PWD/www/|g" ./.env
sed -i '' "s|REPLACEME|$PWD/www|g" ./.env
fi

if [ ! -f docker-compose.yaml ]; then
Expand Down
4 changes: 3 additions & 1 deletion valet/cli/drivers/ValetDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ public function serveStaticFile($staticFilePath, $sitePath, $siteName, $uri)
header('Content-Type: text/html');
header_remove('Content-Type');

header('X-Accel-Redirect: /' . VALET_STATIC_PREFIX . $staticFilePath);
$staticFilePath = preg_replace('#/+#', '/', VALET_STATIC_PREFIX . '/' . $staticFilePath);

header('X-Accel-Redirect: /' . $staticFilePath);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion valet/cli/valet.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
Container::setInstance(new Container);

$version = '0.0.3';
$version = '0.0.4';

$app = new Application('Laravel Valet (Butler)', $version);

Expand Down

0 comments on commit 9c46e1b

Please sign in to comment.