Skip to content

Commit

Permalink
[UNIFY-882] Use real relative path in getSpecUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
flotwig committed Jan 28, 2022
1 parent 03e428f commit 12dcfff
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions packages/server/lib/project_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ import { escapeFilenameInUrl } from './util/escape_filename'

const debug = Debug('cypress:server:project_utils')

const multipleForwardSlashesRe = /[^:\/\/](\/{2,})/g
const multipleForwardSlashesReplacer = (match: string) => match.replace('//', '/')
const backSlashesRe = /\\/g

// format is: http://localhost:<port>/__/#/specs/runner?file=<relative_url>
export const getSpecUrl = ({
spec,
Expand All @@ -31,16 +27,14 @@ export const getSpecUrl = ({
}

const relativeSpecPath = path.relative(projectRoot, path.resolve(projectRoot, spec.relative))
.replace(backSlashesRe, '/')

const escapedRelativePath = escapeFilenameInUrl(relativeSpecPath)

const normalized = `${browserUrl}/#/specs/runner?file=${escapedRelativePath}`
.replace(multipleForwardSlashesRe, multipleForwardSlashesReplacer)
const specUrl = `${browserUrl}#/specs/runner?file=${escapedRelativePath}`

debug('returning spec url %s', normalized)
debug('returning spec url %s', specUrl)

return normalized
return specUrl
}

export const checkSupportFile = async ({
Expand Down

0 comments on commit 12dcfff

Please sign in to comment.