bchavez / bchavez/Bogus

picsum requests are outdated

Open
#418 5 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C#
Stars
9.7k
Forks
538
PR merge metrics
No merged PRs in 30d

Description

### Version Information
| Software | Version(s) |
| ------------------------| ---------- |
| Bogus NuGet Package | 34.0.2 |

### What is the expected behavior?

Expected is that Bogus will create a link based on the [picsum.photos](https://picsum.photos) documentation.

```powershell
https://picsum.photos/id/69/640/480
```

### What is the actual behavior?

A link is created with `?image=id`, which is outdated. It is possible that this request will not be possible anymore at some point.

```powershell
https://picsum.photos/640/480/?image=69
```

### Any possible solutions?

Specify the `Id` via the ULR and not as a parameter:
> (Important: grayscale should be specified via a parameter, however, according to the docu...)

```csharp
public string PicsumUrl(int width = 640, int height = 480, bool grayscale = false, bool blur = false, int? imageId = null)
{
const string Url = "https://picsum.photos";

var sb = new StringBuilder(Url);

var n = imageId ?? this.Random.Number(0, 1084);
sb.Append($"/id/{n}");

sb.Append($"/{width}/{height}");

if (grayscale)
{
sb.Append("?grayscale");
}

if (blur)
{
sb.Append(grayscale ? "&" : "?");
sb.Append("blur");
}

return sb.ToString();
}
```

### How do you reproduce the issue?

Create a picsum link via Bogus.

### Can you identify the location in Bogus' source code where the problem exists?
[DataSet/Images.cs](https://github.com/bchavez/Bogus/blob/b9049abf8b40203c09079741bcb328da95899f81/Source/Bogus/DataSets/Images.cs#L92)

```csharp
sb.Append($"/?image={n}");
```

### If the bug is confirmed, would you be willing to submit a PR?

No, because my recommended solution can already be found here in this report. Thus, this only needs to be added / overwritten.

Contributor guide

Open the contributing guide

Research direction

Open Source/Bogus/DataSets/Images.cs at the PicsumUrl entry point identified in the issue and inspect how the image ID is appended. Compare the generated URL with the current picsum.photos format and the grayscale and blur examples; done means PicsumUrl no longer uses the outdated image query parameter and preserves those options.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.