Hyphen, underscore, or camelCase as word delimiter in URIs?

后端 未结 6 1419
别跟我提以往
别跟我提以往 2020-12-04 04:07

I\'m designing an HTTP-based API for an intranet app. I realize it\'s a pretty small concern in the grand scheme of things, but: should I use hyphens, underscores, o

6条回答
  •  死守一世寂寞
    2020-12-04 05:02

    You should use hyphens in a crawlable web application URL. Why? Because the hyphen separates words (so that a search engine can index the individual words), and is not a word character. Underscore is a word character, meaning it should be considered part of a word.

    Double-click this in Chrome: camelCase
    Double-click this in Chrome: under_score
    Double-click this in Chrome: hyphen-ated

    See how Chrome (I hear Google makes a search engine too) only thinks one of those is two words?

    camelCase and underscore also require the user to use the shift key, whereas hyphenated does not.

    So if you should use hyphens in a crawlable web application, why would you bother doing something different in an intranet application? One less thing to remember.

提交回复
热议问题