question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[3.0] urls argument should be optional

See original GitHub issue

https://github.com/ekalinin/sitemap.js/blob/9cf26148844467104583b5f3c010c73a21d8ea2d/lib/sitemap.ts#L69

Since the default value of urls is an empty array, the urls argument should also be optional. I ran into this issue because I dynamically build my sitemap after initializing:

const sitemap = sm.createSitemap({
    hostname: process.env.SITEMAP_HOSTNAME,
});
sitemap.add("/");
sitemap.add("/some_page");

After updating to 3.0, the above code triggers a type error but it works fine in 2.x

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

1reaction
derduhercommented, Jul 1, 2019

Good spot, I’ll look at this tonight

0reactions
derduhercommented, Jul 2, 2019

@cekvenich looks like I missed it in the createSitemap function. You can instantiate sitemap directly for now as I did make that optional. See the definition of sitemap for the map of function to constructor.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Django optional url parameters - Stack Overflow
The problem is that I want the project_id parameter to be optional. I want /project_config/ and /project_config/12345abdce/ to be equally valid ...
Read more >
URL dispatcher - Django documentation
URLconfs have a hook that lets you pass extra arguments to your view functions, as a Python dictionary. The path() function can take...
Read more >
Optional parameter in url · Issue #1289 · slimphp/Slim - GitHub
We need: Ability to specify optional parameters in the route path; Ability to generate urls via urlFor for routes that have optional parameters....
Read more >
Describing Parameters - Swagger
By default, OpenAPI treats all request parameters as optional. You can add required: true to mark a parameter as required. Note that path...
Read more >
Routing in ASP.NET Core - Microsoft Learn
An optional parameter has a value only when a value is provided by the request URL. Route parameters may have constraints that must...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found