bchavez / Bogus

:card_index: A simple fake data generator for C#, F#, and VB.NET. Based on and ported from the famed faker.js.
Other
8.79k stars 499 forks source link

picsum requests are outdated #418

Open flimtix opened 2 years ago

flimtix commented 2 years ago

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 documentation.

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.

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...)

        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

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.

flimtix commented 2 years ago

In addition, the service lorempixel is no longer available / does not respond.

bchavez commented 2 years ago

I think we'll need to remove the LoremPixel service in our next major update. Thank you for reporting.

prasadtelkikar commented 2 years ago

I will take this, will raise PR soon

marijnz0r commented 3 months ago

@prasadtelkikar Have you found time to create the pull request to remove lorempixel.com from the codebase? @bchavez I would like to contribute by removing lorempixel.com from the codebase altogether. Would this be appreciated?

bchavez commented 3 months ago

Hi @marijnz0r, yes I think removing LoremPixel.com is okay. I think the URLs and site have been broken for a long time.

Just a few more points:

Thanks a bunch for your help.