- Add metadata to login and login-verify pages to prevent indexing. - Update robots.txt to disallow additional sensitive paths. - Enhance sitemap generation to filter by city and include accurate last modified dates. - Refactor canonical URL generation to support multi-domain architecture, ensuring self-canonicalization for city domains. - Remove deprecated CanonicalHandler component and streamline canonical URL handling. - Introduce safe JSON-LD output to prevent XSS vulnerabilities. - Add payment layout with appropriate metadata to prevent indexing. - Conduct a comprehensive technical SEO audit and implement necessary fixes across the application.
59 lines
2.4 KiB
JavaScript
59 lines
2.4 KiB
JavaScript
import { describe, it, expect } from 'vitest';
|
|
import { getStateInfoClient } from '@/lib/getStateInfoClient';
|
|
import { buildCanonicalUrl, buildCanonicalPath, normalizeHost } from '@/lib/getCanonicalUrl';
|
|
|
|
function setLocation(loc) {
|
|
Object.defineProperty(window, 'location', { value: loc, writable: true, configurable: true });
|
|
}
|
|
|
|
describe('getStateInfoClient (window)', () => {
|
|
it('subdomain شناختهشده → شهر و استان', () => {
|
|
setLocation({ host: 'arak-nobat.ir', href: 'https://arak-nobat.ir/' });
|
|
const { matchedCity, matchedState, host } = getStateInfoClient();
|
|
expect(matchedCity?.name).toBe('اراک');
|
|
expect(matchedState?.name).toBe('مرکزی');
|
|
expect(host).toBe('arak-nobat.ir');
|
|
});
|
|
|
|
it('host ناشناخته → بدون تطبیق', () => {
|
|
setLocation({ host: 'zzz.ir', href: 'https://zzz.ir/' });
|
|
expect(getStateInfoClient().matchedCity).toBeUndefined();
|
|
});
|
|
});
|
|
|
|
describe('buildCanonicalUrl (self-canonical per-host)', () => {
|
|
it('دامنهی شهری → self-canonical روی همان دامنه', () => {
|
|
expect(buildCanonicalUrl('arak-nobat.ir', '/doctors')).toBe('https://arak-nobat.ir/doctors');
|
|
});
|
|
|
|
it('دامنهی اصلی → self-canonical روی دامنهی اصلی', () => {
|
|
expect(buildCanonicalUrl('nobat724.com', '/doctors')).toBe('https://nobat724.com/doctors');
|
|
});
|
|
|
|
it('www و حروف بزرگ نرمال میشوند', () => {
|
|
expect(buildCanonicalUrl('WWW.Nobat724.com', '/x')).toBe('https://nobat724.com/x');
|
|
});
|
|
|
|
it('هاست dev با پورت → http و حفظ پورت', () => {
|
|
expect(buildCanonicalUrl('yazd-nobat.localhost:3000', '/doctors')).toBe(
|
|
'http://yazd-nobat.localhost:3000/doctors'
|
|
);
|
|
});
|
|
|
|
it('query string و trailing slash حذف میشوند', () => {
|
|
expect(buildCanonicalUrl('arak-nobat.ir', '/doctors/?specialty=قلب')).toBe(
|
|
'https://arak-nobat.ir/doctors'
|
|
);
|
|
});
|
|
|
|
it('ریشه دستنخورده میماند', () => {
|
|
expect(buildCanonicalUrl('arak-nobat.ir', '/')).toBe('https://arak-nobat.ir/');
|
|
expect(buildCanonicalPath('/')).toBe('/');
|
|
});
|
|
|
|
it('هاست خالی → دامنهی پیشفرض', () => {
|
|
expect(normalizeHost('')).toBe('nobat724.com');
|
|
expect(buildCanonicalUrl(null, '/x')).toBe('https://nobat724.com/x');
|
|
});
|
|
});
|