Skip to content

Commit

Permalink
Support locales in ping output
Browse files Browse the repository at this point in the history
Loosen the regex to search for a time value,
to support non-english output of the ping command.

Since the output is generic in all languages we dont
need to look for a specific english term.

Refs geerlingguy#5 Refs geerlingguy#49
  • Loading branch information
pixelbrackets committed Aug 6, 2020
1 parent 7ff6296 commit 4ff7eb7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions JJG/Ping.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ private function pingExec() {

// If the result line in the output is not empty, parse it.
if (!empty($output[1])) {
// Search for a 'time' value in the result line.
$response = preg_match("/time(?:=|<)(?<time>[\.0-9]+)(?:|\s)ms/", $output[1], $matches);
// Search for a time value in the result line.
$response = preg_match("/(?:\w=|\w<)(?<time>[\.0-9]+)(?:|\s)ms/", $output[1], $matches);

// If there's a result and it's greater than 0, return the latency.
if ($response > 0 && isset($matches['time'])) {
Expand Down

0 comments on commit 4ff7eb7

Please sign in to comment.