Skip to content

Commit

Permalink
fixes #10
Browse files Browse the repository at this point in the history
  • Loading branch information
abdumu committed Apr 23, 2019
1 parent c2d1d35 commit e43ca60
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/SearchAndReplace.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public function perform($search, $replace, $options = null)
$currentContent = $this->givenContent;

if ($options & self::INSIDE_CLASSE_PROP) {
$regexStart = '(?<start>class\s*=\s*["\'].*?)';
$regexEnd = '(?<end>.*?["\'])';
$regexStart = '(?<start>class\s*=\s*(?<quotation>["\'])((?!\k<quotation>).)*)';
$regexEnd = '(?<end>((?!\k<quotation>).)*\k<quotation>)';
} elseif ($options & self::AFTER_APPLY_DIRECTIVE) {
$regexStart = '(?<start>@apply\s*.*?)';
$regexEnd = '(?<end>.*?[;\n])';
Expand Down
36 changes: 36 additions & 0 deletions tests/UpdaterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,40 @@ class="group cursor-pointer bg-grey-dark"
}">')->convert()->get()
);
}

/** @test */
public function it_convert_class_content_only()
{
$this->assertContains(
'http://www.w3.org/2000/svg',
$this->updater->setContent('<svg class="fill-current h-6 w-6" xmlns="http://www.w3.org/2000/svg"')->convert()->get()
);

$code = '<span class="text-grey-100 text-sm pr-4">{{ Auth::user()->name }}</span>
<div v-if="showExtraButtons" class="ml-4">
Selected: {{ selectedUsers.length }}
</div>
<span class="pin-t mt-3"></span>
<button-orange></button-orange>
<span class="pin-t mt-3"></span>
';

$convertedCode = $this->updater->setContent($code)->convert()->get();

$this->assertContains(
'{{ Auth::user()->name }}',
$convertedCode
);

$this->assertContains(
'Selected: ',
$convertedCode
);

$this->assertContains(
'<button-orange>',
$convertedCode
);
}

}

0 comments on commit e43ca60

Please sign in to comment.