Skip to content
This repository has been archived by the owner on Sep 12, 2022. It is now read-only.

Commit

Permalink
#45 Add StripComment stage for string preprocessor
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Kleinhans committed Dec 13, 2016
1 parent 27d0d9b commit 1bb42dc
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/StackFormation/PreProcessor/Stage/String/StripComments.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace StackFormation\PreProcessor\Stage\String;

use StackFormation\PreProcessor\Stage\AbstractStringPreProcessorStage;

class StripComments extends AbstractStringPreProcessorStage {

/**
* @param string $content
* @return string
*/
public function invoke($content)
{
// there's a problem with '"http://example.com"' being converted to '"http:'
// $content = preg_replace('~//[^\r\n]*|/\*.*?\*/~s', '', $content);

// there's a problem with "arn:aws:s3:::my-bucket/*"
// $content = preg_replace('~/\*.*?\*/~s', '', $content);

// quick workaround: don't allow quotes
return preg_replace('~/\*[^"]*?\*/~s', '', $content);
}
}

0 comments on commit 1bb42dc

Please sign in to comment.