UNPKG

next-auth

Version:

Authentication for Next.js

25 lines (21 loc) 629 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = parseUrl; function parseUrl(url) { const defaultHost = 'http://localhost:3000'; const defaultPath = '/api/auth'; if (!url) { url = `${defaultHost}${defaultPath}`; } const protocol = url.startsWith('http:') ? 'http' : 'https'; url = url.replace(/^https?:\/\//, '').replace(/\/$/, ''); const [_host, ..._path] = url.split('/'); const baseUrl = _host ? `${protocol}://${_host}` : defaultHost; const basePath = _path.length > 0 ? `/${_path.join('/')}` : defaultPath; return { baseUrl, basePath }; }