debian-mirror-gitlab/app/assets/javascripts/blob/utils.js
2023-01-12 18:35:48 +00:00

18 lines
583 B
JavaScript

import { getBaseURL } from '~/lib/utils/url_utility';
const blameLinesPerPage = document.querySelector('.js-per-page')?.dataset?.blamePerPage;
export const getPageParamValue = (lineNum, blamePerPage = blameLinesPerPage) => {
if (!blamePerPage) return '';
const page = Math.ceil(parseInt(lineNum, 10) / parseInt(blamePerPage, 10));
return page <= 1 ? '' : page;
};
export const getPageSearchString = (path, page) => {
if (!page) return '';
const url = new URL(path, getBaseURL());
url.searchParams.set('page', page);
return url.search;
};
export default () => ({});