Skip to content

Use the URL builder in routes #270

@Gauravjeetsingh

Description

@Gauravjeetsingh

from controller/shabad.js

    resultsInfo.pages.nextPage = `${req.protocol}://${req.get('host')}${req.baseUrl}${
            req.path
          }?${Object.keys(req.query)
            .map(key => `${key}=${encodeURIComponent(req.query[key])}`)
            .join('&')}`;

Maybe we can divide this into two different statements (for base path and query keys.

Also, can we use a URL builder instead?

Something like:

const url = require('url');
const myURL = url.format({
  protocol: req.protocol,
  hostname: req.get('host'),
  pathname: '/some/path',
  query: {
    key: 'value'
  }
});

Originally posted by @mandeepryaz in #268 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions