Request: Introduce a `req.completeURL()` method

オープン
#4,697 コメント 3 件 リアクション 4 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
express, javascript, node.js
領域
api, backend

調査の方向性

まず、issue で指定されている Express のリクエストプロパティ req.originURL、req.protocol、req.get('host')、req.originalUrl を確認し、リンク先の Stack Overflow の推奨事項と比較します。Express が一貫した名前の完全な URL 用リクエストメソッドを提供し、その動作が報告された完全な URL の例をカバーできれば、作業は完了です。

索引モデルが issue の本文から書いたものです。

説明

discuss enhancement ideas

When communicating with other systems, sometimes we need to send the complete URL. E.g. include the full http://localhost:30000/foo?a=45 in the response when accessing that URL.

req.originURL becomes /foo?a=45, but the scheme and hostname parts are lost.

node.js - How to get the full URL in Express? - Stack Overflow has 578 upvotes and the top answer has 871 upvotes. But there are also a gazillion other answers of varying correctness.

The suggestion from the top answer is:

var fullUrl = req.protocol + '://' + req.get('host') + req.originalUrl;

Could we "officialize" this and turn it into req.completeUrl() (or whatever name you prefer) so everybody uses the same solution that works reliably? I'm happy to create a PR for this one-liner, I just wanted to ask here first...

主要言語
JavaScript
スター
69.7k
フォーク
25.6k
平均マージ
2日 9時間
マージ済み PR(30日)
4

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

expressjs/express のほかの issue

expressjs/express の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。