Skip to content

Commit

Permalink
Support spaces in .net file paths (#836)
Browse files Browse the repository at this point in the history
  • Loading branch information
xt0rted authored Apr 12, 2020
1 parent 818ab62 commit 9ddbd77
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 2 deletions.
5 changes: 5 additions & 0 deletions e2e/fixtures/dotnet/classic/Project.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@
<None Update="..\Directory.Build.props" />
</ItemGroup>

<ItemGroup>
<!-- @OctoLinkerResolve(<root>/dotnet/foo bar/test file.cs) -->
<Content Include="../foo bar/test file.cs" />
</ItemGroup>

</Project>
Empty file.
5 changes: 5 additions & 0 deletions e2e/fixtures/dotnet/sdk/Project.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,9 @@
<None Update="../Directory.Build.props" />
</ItemGroup>

<ItemGroup>
<!-- @OctoLinkerResolve(<root>/dotnet/foo bar/test file.cs) -->
<Content Include="../foo bar/test file.cs" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion packages/core/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function insertLinks({

for (const item of urls) {
if (item.type === 'internal-link') {
if (githubTree.includes(item.path)) {
if (githubTree.includes(item.path.replace(/%20/g, ' '))) {
link.href = item.url;
if (process.env.OCTOLINKER_LIVE_DEMO) {
link.href = injectLiveDemoUrl(link.href);
Expand Down
8 changes: 7 additions & 1 deletion packages/helper-grammar-regex-collection/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ const captureQuotedWord = regex`
['"] # end quote
`;

const captureSpacedQuotedWord = regex`
['"] # beginning quote
(?<$1>[^'"]+) # capture the word inside the quotes
['"] # end quote
`;

const captureJsQuotedWord = regex`
['"\`] # beginning quote
(?<$1>[^'"\`\s]+) # capture the word inside the quotes
Expand Down Expand Up @@ -220,6 +226,6 @@ export const NET_PROJ_FILE_REFERENCE = regex`
<(Compile|Content|EmbeddedResource|None|ProjectReference)
\s+
.*
(Include|Update)=${captureQuotedWord}
(Include|Update)=${captureSpacedQuotedWord}
.*/?>
`;
3 changes: 3 additions & 0 deletions packages/helper-grammar-regex-collection/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,9 @@ const fixtures = {
['<Compile Include="foo">', ['foo']],
['<Compile Update="foo">', ['foo']],
['<Content Include="foo">', ['foo']],
['<Content Include="foo/bar foo">', ['foo/bar foo']],
['<Content Include="foo bar/bar">', ['foo bar/bar']],
['<Content Include="foo bar/bar foo">', ['foo bar/bar foo']],
['<Content Update="foo">', ['foo']],
['<EmbeddedResource Include="foo">', ['foo']],
['<EmbeddedResource Update="foo">', ['foo']],
Expand Down

0 comments on commit 9ddbd77

Please sign in to comment.