mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
sourceMapBaseUrl wip implementation
This commit is contained in:
@@ -10,10 +10,9 @@ describe('JavaScriptObfuscatorInternal', () => {
|
||||
describe(`setSourceMapUrl (url: string)`, () => {
|
||||
let javaScriptObfuscator: JavaScriptObfuscatorInternal,
|
||||
obfuscationResult: IObfuscationResult,
|
||||
sourceMapUrl: string;
|
||||
sourceMapUrl: string = 'test.map.js';
|
||||
|
||||
it('should link obfuscated code with source map', () => {
|
||||
sourceMapUrl = 'test.map.js';
|
||||
javaScriptObfuscator = new JavaScriptObfuscatorInternal(
|
||||
`var test = 1;`,
|
||||
Object.assign({}, NO_CUSTOM_NODES_PRESET, {
|
||||
@@ -33,23 +32,25 @@ describe('JavaScriptObfuscatorInternal', () => {
|
||||
assert.isOk(JSON.parse(obfuscationResult.getSourceMap()).mappings);
|
||||
});
|
||||
|
||||
it('should properly add source map import to the obfuscated code if `sourceMapBaseUrl` is set', () => {
|
||||
sourceMapUrl = 'http://localhost:9000/';
|
||||
it('should properly add base url to source map import inside obfuscated code if `sourceMapBaseUrl` is set', () => {
|
||||
let sourceMapBaseUrl: string = 'http://localhost:9000';
|
||||
|
||||
javaScriptObfuscator = new JavaScriptObfuscatorInternal(
|
||||
`var test = 1;`,
|
||||
Object.assign({}, NO_CUSTOM_NODES_PRESET, {
|
||||
sourceMap: true,
|
||||
sourceMapBaseUrl: sourceMapUrl
|
||||
sourceMapBaseUrl: sourceMapBaseUrl
|
||||
})
|
||||
);
|
||||
|
||||
javaScriptObfuscator.obfuscate();
|
||||
javaScriptObfuscator.setSourceMapUrl(sourceMapUrl);
|
||||
|
||||
obfuscationResult = javaScriptObfuscator.getObfuscationResult();
|
||||
|
||||
assert.match(
|
||||
obfuscationResult.getObfuscatedCode(),
|
||||
new RegExp(`sourceMappingURL=${sourceMapUrl}$`))
|
||||
new RegExp(`sourceMappingURL=${sourceMapBaseUrl}/${sourceMapUrl}$`))
|
||||
;
|
||||
assert.isOk(JSON.parse(obfuscationResult.getSourceMap()).mappings);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user