Skip to content

Commit

Permalink
Run Linter
Browse files Browse the repository at this point in the history
  • Loading branch information
PineappleIOnic committed Aug 16, 2023
1 parent 409718f commit d93324d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Migration/Sources/Firebase.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,8 @@ private function exportBuckets(int $batchsize)
}
}

private function sanitizeBucketId($id) {
private function sanitizeBucketId($id)
{
// Step 1: Check if the ID looks like a URL (contains ".")
if (strpos($id, '.') !== false) {
// If it looks like a URL, try to extract the subdomain
Expand All @@ -562,18 +563,18 @@ private function sanitizeBucketId($id) {
$id = $parts[0];
}
}

// Step 2: Ensure the ID contains at most 36 characters
$id = substr($id, 0, 36);

// Step 3: Remove invalid characters using a regular expression
$id = preg_replace('/[^a-zA-Z0-9\._-]/', '', $id);

// Step 4: Ensure the ID doesn't start with a special character
if (preg_match('/^[._-]/', $id)) {
$id = 'a' . substr($id, 1);
$id = 'a'.substr($id, 1);
}

return $id;
}

Expand Down

0 comments on commit d93324d

Please sign in to comment.