Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix path not properly being shown without RnDiffApp #291

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/common/DiffViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const DiffViewer = ({
}

const diffSectionProps = {
diff: diff,
diff,
getDiffKey: getDiffKey,
completedDiffs: completedDiffs,
fromVersion: fromVersion,
Expand Down
6 changes: 2 additions & 4 deletions src/components/common/DownloadFileButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import { DownloadOutlined } from '@ant-design/icons'
import { getBinaryFileURL } from '../../utils'

const DownloadFileButton = styled(
({ visible, version, path, packageName, ...props }) => {
console.info(visible, version, path, packageName)
return visible ? (
({ visible, version, path, packageName, ...props }) =>
visible ? (
<Button
{...props}
type="ghost"
Expand All @@ -17,7 +16,6 @@ const DownloadFileButton = styled(
href={getBinaryFileURL({ packageName, version, path })}
/>
) : null
}
)`
color: #24292e;
font-size: 12px;
Expand Down
2 changes: 1 addition & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const DEFAULT_APP_NAME = 'RnDiffApp'
export const DEFAULT_APP_NAMES = ['RnDiffApp', 'DiffApp']

export const PACKAGE_NAMES = {
RN: 'react-native',
Expand Down
15 changes: 11 additions & 4 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import semver from 'semver/preload'
import {
RN_DIFF_REPOSITORIES,
DEFAULT_APP_NAME,
DEFAULT_APP_NAMES,
PACKAGE_NAMES,
RN_CHANGELOG_URLS
} from './constants'
Expand Down Expand Up @@ -30,17 +30,24 @@ export const getBinaryFileURL = ({ packageName, version, path }) => {
}

export const removeAppPathPrefix = (path, appName) =>
path.replace(new RegExp(`${appName || DEFAULT_APP_NAME}/`), '')
path
.replace(new RegExp(`${appName || DEFAULT_APP_NAMES.join('|')}/`), '')
.replace(/^\//, '')

export const replaceWithProvidedAppName = (path, appName) => {
if (!appName) {
return path
}

return path
.replace(new RegExp(DEFAULT_APP_NAME, 'g'), appName)
.replace(new RegExp(DEFAULT_APP_NAMES.join('|'), 'g'), appName)
.replace(
new RegExp(DEFAULT_APP_NAME.toLowerCase(), 'g'),
new RegExp(
DEFAULT_APP_NAMES.map(defaultAppName =>
defaultAppName.toLowerCase()
).join('|'),
'g'
),
appName.toLowerCase()
)
}
Expand Down