[express] originalUrl

해피데빙·2023년 7월 12일
0

req.originalUrl

  • This property is much like req.url;
  • however, it retains the original request URL,
  • allowing you to rewrite req.url freely for internal routing purposes. For example, the “mounting” feature of app.use() will rewrite req.url to strip the mount point.
// GET /search?q=something
console.dir(req.originalUrl)
// => '/search?q=something'

req.originalUrl is available both in middleware and router objects, and is a combination of req.baseUrl and req.url. Consider following example:

app.use('/admin', function (req, res, next) { // GET 'http://www.example.com/admin/new?sort=desc'
  console.dir(req.originalUrl) // '/admin/new?sort=desc'
  console.dir(req.baseUrl) // '/admin'
  console.dir(req.path) // '/new'
  next()
})

정리

url = scheme + domain + baseUrl + path + query (etc.) [originalUrl]

punycode

  • representation of Unicode with the limited ASCII character subset used for Internet hostnames. (unicode 중에 인터넷 호스트네임으로 사용하기 좋은 제한적인 아스키 글자 그룹)

예시

the Chinese domain “短. co” is represented in Punycode as “xn--s7y.co”
German city of “München” becomes the Punycode “xn--mnchen-3ya” because the letter ü is not available in English.
Note: You can convert text on a site like Punycoder to see how other names are converted.

  • host names containing Unicode characters are transcoded to a subset of ASCII consisting of letters, digits, and hyphens, which is called the letter–digit–hyphen (LDH) subset.

이미지 업로드

  • FileReader 객체
    : 웹 애플리케이션이 비동기적으로 데이터를 읽기 위하여 읽을 파일을 가리키는 File 혹은 Blob 객체를 이용해 파일의 내용을(혹은 raw data 버퍼로) 읽고 사용자의 컴퓨터에 저장하는 것을 가능하게 해줍니다.

FileList 객체

  • input 태그를 이용하여 유저가 선택한 파일들의 결과로 반환

DataTransfer (en-US) 객체 혹은 HTMLCanvasElement의 mozGetAsFile() API

  • 드래그 앤 드랍으로 반환됨
FileReader.error 
FileReader.readySTate
FileReader.result
FileReader.onload

base64 인코딩

dataURL 인코딩

downScalImage 인코딩

profile
노션 : https://garrulous-gander-3f2.notion.site/c488d337791c4c4cb6d93cb9fcc26f17

0개의 댓글