vendredi 11 août 2023

What's the name of this when using the ID and title in URL of a web resource

For example, the StackOverflow question URls look like this:

https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it

Somewhere in the code, there's a parser that does the following:

  • hash: ""
  • hostname: "stackoverflow.com"
  • pathname: "/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it"
  • port: ""
  • protocol: "https:"
  • search: ""

And take the pathname's value and parse it using this pattern: /questions/<ID>/<Title>.

When the parser runs what it matters to identify the post is basically the ID, and the title can be basically anything, test it yourself and the following URLs will redirect you to the correct URL:

  • https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it-extra-text
  • https://stackoverflow.com/questions/218384/this-is-a-different-text
  • https://stackoverflow.com/questions/218384 <-- no text at all

Does anyone have an idea what this pattern is called and have references to it?

Aucun commentaire:

Enregistrer un commentaire