Skip to content

Commit

Permalink
Merge pull request #1018 from skaut/linebreak-fix
Browse files Browse the repository at this point in the history
Fixed parsing of readmes with Windows linebreaks
  • Loading branch information
marekdedic authored Aug 30, 2023
2 parents 1a72ec1 + cc79afb commit 5867fa1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions __tests__/tested-version.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ describe("[env variable mock]", () => {
"Tested up to: 0.42",
"Tested up to:0.42",
"LINE1\nNot Tested up to: 0.41\nTested up to: 0.42\nLINE2",
"LINE1\r\nNot Tested up to: 0.41\r\nTested up to: 0.42\r\nLINE2",
" Tested up to: 0.42",
" Tested up to: 0.42",
"\tTested up to: 0.42",
"\nTested up to: 0.42\n",
"\r\nTested up to: 0.42\r\n",
"Tested up to: 0.42",
])("testedVersion works correctly", async (readme) => {
expect.assertions(1);
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10612,7 +10612,7 @@ function readme(config) {
function testedVersion(config) {
return __awaiter(this, void 0, void 0, function* () {
const readmeContents = yield readme(config);
for (const line of readmeContents.split("\n")) {
for (const line of readmeContents.split(/\r?\n/)) {
const matches = [...line.matchAll(/^[\s]*Tested up to:[\s]*([.\d]+)$/g)];
if (matches.length !== 1) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/tested-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function readme(config: Config): Promise<string> {

export async function testedVersion(config: Config): Promise<string> {
const readmeContents = await readme(config);
for (const line of readmeContents.split("\n")) {
for (const line of readmeContents.split(/\r?\n/)) {
const matches = [...line.matchAll(/^[\s]*Tested up to:[\s]*([.\d]+)$/g)];
if (matches.length !== 1) {
continue;
Expand Down

0 comments on commit 5867fa1

Please sign in to comment.