New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

unreach-util

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unreach-util - npm Package Compare versions

Comparing version 0.5.1 to 0.5.2

5

env.js

@@ -1,2 +0,3 @@

const env = process.env.REACT_APP_ENV || process.env.NODE_ENV || 'development';
export default env;
export default function() {
return process.env.REACT_APP_ENV || process.env.NODE_ENV || 'development';
}

2

env.test.js

@@ -5,4 +5,4 @@ import env from './env';

it('test', () => {
expect(env).toBe('test');
expect(env()).toBe('test');
});
});
{
"name": "unreach-util",
"version": "0.5.1",
"version": "0.5.2",
"description": "前端工具基础库",

@@ -5,0 +5,0 @@ "main": "index.js",

import axios from 'axios';
import env from './env';
const serverHost = (/(\.[-\w]+\.[-\w]+)$/).exec(window.location.hostname)[1];
const serverHost = /(\.[-\w]+\.[-\w]+)$/.exec(window.location.hostname)[1];
async function request({ method = 'get', scope, url, params, data }) {
url = `${getHost(scope)}/api/${url}`;
if (!url.startsWith('http')) {
url = `${getHost(scope)}/api/${url}`;
}
if (method === 'get') {

@@ -40,7 +41,7 @@ params = { ...params, ...data, _: Date.now() };

function getHost(scope) {
return env === 'development' ?
`https://${scope}.dev${serverHost}` :
`https://${scope}${serverHost}`;
return env() === 'development'
? `https://${scope}.dev${serverHost}`
: `https://${scope}${serverHost}`;
}
export default { request, get, post, postSync };

@@ -7,9 +7,10 @@ import qs from 'querystring';

const getLoginUserId = cached(async() => {
const data = await request.get('member', 'account/query');
return data && data.id;
const getLoginUserId = cached(async () => {
const data = await request.get(
'member',
'https://member.unreach.io/api/account/query'
);
return data && data.user && data.user.id;
});
export default async function track({ type, id, data }) {

@@ -22,3 +23,2 @@ debug('track: [%s] %s', type, id);

export async function trackSync({ type, id, data }) {

@@ -33,3 +33,2 @@ debug('track sync: [%s] %s', type, id);

async function getTrackUrl({ type, id, data, ext = '' }) {

@@ -42,5 +41,5 @@ type = type || 'click';

const url = window.location.href.replace(/#.*$/, ''); // remove hash
const url = window.location.href.replace(/#.*$/, ''); // remove hash
const query = {
APIVersion: '0.6.0', // 保留字段,必选
APIVersion: '0.6.0', // 保留字段,必选
url,

@@ -55,7 +54,7 @@ __topic__: userId || '',

const trackUrl = 'https://learninqgt.cn-hangzhou.log.aliyuncs.com/logstores/document/track';
const trackUrl =
'https://learninqgt.cn-hangzhou.log.aliyuncs.com/logstores/document/track';
return `${trackUrl}${ext}?${qs.stringify(query)}`;
}
function cached(fn) {

@@ -62,0 +61,0 @@ let called = false;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc