fix: strip hash and search from project name #251
This commit is contained in:
@@ -8,7 +8,7 @@ import config from '../config/config';
|
|||||||
import { SendHeartbeat } from '../types/heartbeats';
|
import { SendHeartbeat } from '../types/heartbeats';
|
||||||
import { GrandTotal, SummariesPayload } from '../types/summaries';
|
import { GrandTotal, SummariesPayload } from '../types/summaries';
|
||||||
import { ApiKeyPayload, AxiosUserResponse, User } from '../types/user';
|
import { ApiKeyPayload, AxiosUserResponse, User } from '../types/user';
|
||||||
import { IS_FIREFOX, IS_EDGE, generateProjectFromDevSites } from '../utils';
|
import { IS_EDGE, IS_FIREFOX, generateProjectFromDevSites } from '../utils';
|
||||||
import { getApiKey } from '../utils/apiKey';
|
import { getApiKey } from '../utils/apiKey';
|
||||||
import changeExtensionState from '../utils/changeExtensionState';
|
import changeExtensionState from '../utils/changeExtensionState';
|
||||||
import contains from '../utils/contains';
|
import contains from '../utils/contains';
|
||||||
@@ -285,6 +285,7 @@ class WakaTimeCore {
|
|||||||
apiKey: string,
|
apiKey: string,
|
||||||
navigationPayload: Record<string, unknown>,
|
navigationPayload: Record<string, unknown>,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
console.log('Sending Heartbeat', heartbeat);
|
||||||
let payload;
|
let payload;
|
||||||
|
|
||||||
const loggingType = await this.getLoggingType();
|
const loggingType = await this.getLoggingType();
|
||||||
|
|||||||
@@ -2,12 +2,14 @@ export const IS_EDGE = navigator.userAgent.includes('Edg');
|
|||||||
export const IS_FIREFOX = navigator.userAgent.includes('Firefox');
|
export const IS_FIREFOX = navigator.userAgent.includes('Firefox');
|
||||||
export const IS_CHROME = IS_EDGE === false && IS_FIREFOX === false;
|
export const IS_CHROME = IS_EDGE === false && IS_FIREFOX === false;
|
||||||
|
|
||||||
export const generateProjectFromDevSites = (url: string): string | null => {
|
export const generateProjectFromDevSites = (siteUrl: string): string | null => {
|
||||||
const githubUrls = ['https://github.com/', 'https://github.dev/'];
|
const url = new URL(siteUrl);
|
||||||
|
const githubUrls = ['github.com', 'github.dev'];
|
||||||
for (const githubUrl of githubUrls) {
|
for (const githubUrl of githubUrls) {
|
||||||
if (url.startsWith(githubUrl)) {
|
if (url.host === githubUrl) {
|
||||||
const newUrl = url.replace(githubUrl, '');
|
// input: https://github.com/wakatime/browser-wakatime?tab=readme-ov-file#development-instructions
|
||||||
return newUrl.split('/')[1] || null;
|
// output: browser-wakatime
|
||||||
|
return url.pathname.split('/')[2] || null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user