Skip to content

Instantly share code, notes, and snippets.

@trinhvietvan
trinhvietvan / api.md
Last active March 25, 2026 16:59

Authentication

  • Method: POST
  • Url: /api/auth
  • Request body:
    • uid: Firebase user uid
    • idToken: Firebase user idToken
    • pushToken: Firebase cloud messaging token
  • Response json:
{
@trinhvietvan
trinhvietvan / slugify.js
Created August 10, 2019 07:16 — forked from hagemann/slugify.js
Slugify makes a string URI-friendly
function slugify(string) {
const a = 'àáäâãåăæąçćčđďèéěėëêęğǵḧìíïîįłḿǹńňñòóöôœøṕŕřßşśšșťțùúüûǘůűūųẃẍÿýźžż·/_,:;'
const b = 'aaaaaaaaacccddeeeeeeegghiiiiilmnnnnooooooprrsssssttuuuuuuuuuwxyyzzz------'
const p = new RegExp(a.split('').join('|'), 'g')
return string.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(p, c => b.charAt(a.indexOf(c))) // Replace special characters
.replace(/&/g, '-and-') // Replace & with 'and'
.replace(/[^\w\-]+/g, '') // Remove all non-word characters